加入收藏 | 设为首页 | 会员中心 | 我要投稿 甘孜站长网 (https://www.0836zz.com.cn/)- 运维、物联设备、数据计算、智能推荐、云管理!
当前位置: 首页 > 大数据 > 正文

Flume-接入Hive数仓搭建步骤

发布时间:2021-06-04 14:58:58 所属栏目:大数据 来源:互联网
导读:实时流接入数仓,基本在大公司都会有,在Flume1.8以后支持taildir source, 其有以下几个特点,而被广泛使用: 使用正则表达式匹配目录中的文件名 监控的文件中,一旦有数据写入,Flume就会将信息写入到指定的Sink 高可靠,不会丢失数据 不会对跟踪文件有任何
实时流接入数仓,基本在大公司都会有,在Flume1.8以后支持taildir source, 其有以下几个特点,而被广泛使用:
使用正则表达式匹配目录中的文件名
监控的文件中,一旦有数据写入,Flume就会将信息写入到指定的Sink
高可靠,不会丢失数据
不会对跟踪文件有任何处理,不会重命名也不会删除
不支持Windows,不能读二进制文件。支持按行读取文本文件
本文以开源Flume流为例,介绍流接入HDFS ,后面在其上面建立ods层外表。
1.1 taildir source配置
a1.sources.r1.type = TAILDIR 
a1.sources.r1.positionFile = /opt/hoult/servers/conf/startlog_position.json 
a1.sources.r1.filegroups = f1 
a1.sources.r1.filegroups.f1 =/opt/hoult/servers/logs/start/.*log 
1.2 hdfs sink 配置
a1.sinks.k1.type = hdfs 
a1.sinks.k1.hdfs.path = /user/data/logs/start/logs/start/%Y-%m-%d/ 
a1.sinks.k1.hdfs.filePrefix = startlog. 
# 配置文件滚动方式(文件大小32M) 
a1.sinks.k1.hdfs.rollSize = 33554432 
a1.sinks.k1.hdfs.rollCount = 0 
a1.sinks.k1.hdfs.rollInterval = 0 
a1.sinks.k1.hdfs.idleTimeout = 0 
a1.sinks.k1.hdfs.minBlockReplicas = 1 
# 向hdfs上刷新的event的个数 
a1.sinks.k1.hdfs.batchSize = 100 
# 使用本地时间 
a1.sinks.k1.hdfs.useLocalTimeStamp = true  
1.3 Agent的配置
a1.sources = r1 
a1.sinks = k1 
a1.channels = c1 
# taildir source 
a1.sources.r1.type = TAILDIR 
a1.sources.r1.positionFile = /opt/hoult/servers/conf/startlog_position.json 
a1.sources.r1.filegroups = f1 
a1.sources.r1.filegroups.f1 = /user/data/logs/start/.*log 
# memorychannel 
a1.channels.c1.type = memory 
a1.channels.c1.capacity = 100000 
a1.channels.c1.transactionCapacity = 2000 
# hdfs sink 
a1.sinks.k1.type = hdfs 
a1.sinks.k1.hdfs.path = /opt/hoult/servers/logs/start/%Y-%m-%d/ 
a1.sinks.k1.hdfs.filePrefix = startlog. 
# 配置文件滚动方式(文件大小32M) 
a1.sinks.k1.hdfs.rollSize = 33554432 
a1.sinks.k1.hdfs.rollCount = 0 
a1.sinks.k1.hdfs.rollInterval = 0 
a1.sinks.k1.hdfs.idleTimeout = 0 
a1.sinks.k1.hdfs.minBlockReplicas = 1 
# 向hdfs上刷新的event的个数 
a1.sinks.k1.hdfs.batchSize = 1000 
# 使用本地时间 
a1.sinks.k1.hdfs.useLocalTimeStamp = true 
# Bind the source and sink to the channel 
a1.sources.r1.channels = c1 
a1.sinks.k1.channel = c1  
/opt/hoult/servers/conf/flume-log2hdfs.conf
1.4 启动
flume-ng agent --conf-file /opt/hoult/servers/conf/flume-log2hdfs.conf -name a1 -Dflume.roog.logger=INFO,console 
 
export JAVA_OPTS="-Xms4000m -Xmx4000m -Dcom.sun.management.jmxremote" 
# 要想使配置文件生效,还要在命令行中指定配置文件目录 
flume-ng agent --conf /opt/hoult/servers/flume-1.9.0/conf --conf-file /opt/hoult/servers/conf/flume

(编辑:甘孜站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读