flume-NG集群搭建

1、安装下载flume  

下载地址 http://flume.apache.org

mkdir /opt/flume/   

tar -zxvf apache-flume-1.8.0-bin.tar.gz

 

修改配置文件 mv flume-env.sh.template flume-env.sh

mv flume-conf.properties.template flume-hdfs.properties

2、配置环境变量

mkdir /etc/profile.d/flume.sh

vim /etc/profile.d/flume.sh/

source /etc/profile

3、执行运行

上传hdfs文件系统,需要修改flume-env.sh,内容如下

去掉注释后修改成 export JAVA_HOME=/usr/local/java/jdk1.8.0_151

去掉注释修改成 FLUME_CLASSPATH="/opt/hadoop-3.0.0/share/hadoop/hdfs/*"

flume配置如下

#类型 AVRO spooldir netcat HTTP
a1.sources = sourceMqtt
a1.sinks = sinkMqtt
a1.channels = channelMqtt

# Describe/configure the source
a1.sources.sourceMqtt.type = com.lpcloud.emqflumesource.MQTTSource

# Describe the sink
#类型 file_roll avro HDFS
a1.sinks.sinkMqtt.type = hdfs  
#写入hdfs的路径,需要包含文件系统标识
a1.sinks.sinkMqtt.hdfs.path = hdfs://leapbigdata/leapdata/testlogs/%Y-%m-%d/%H
#默认值:SequenceFile 文件格式,包括:SequenceFile, #DataStream,CompressedStream当使用DataStream时候,文件不会被压缩,不需要设置hdfs.codeC;当使用CompressedStream时候,必须设置一个正确的hdfs.codeC值;
a1.sinks.sinkMqtt.hdfs.fileType = DataStream
#写sequence文件的格式。包含:Text, Writable(默认)
a1.sinks.sinkMqtt.hdfs.writeFormat=TEXT
#codeC 文件压缩格式,包括:gzip, bzip2, lzo, lzop, snappy
#默认值:FlumeData 写入hdfs的文件名前缀,可以使用flume提供的日期及%{host}表达式
a1.sinks.sinkMqtt.hdfs.filePrefix = gbt32960Hdfs
#默认值:100 每个批次刷新到HDFS上的events数量
a1.sinks.sinkMqtt.hdfs.batchSize = 1000
#默认值:1024 当临时文件达到该大小(单位:bytes)时,滚动成目标文件;如果设置成0,则表示不根据临时文件大小来滚动文件
a1.sinks.sinkMqtt.hdfs.rollSize = 0
#当events数据达到该数量时候,将临时文件滚动成目标文件;如果设置成0,则表示不根据events数据来滚动文件
a1.sinks.sinkMqtt.hdfs.rollCount = 10
#默认值:30 hdfs sink间隔多长将临时文件滚动成最终目标文件,单位:秒;如果设置成0,则表示不根据时间来滚动文件;
a1.sinks.sinkMqtt.hdfs.rollInterval = 0

#当目前被打开的临时文件在该参数指定的时间(秒)内,没有任何数据写入,则将该临时文件关闭并重命名成目标文件
a1.sinks.sinkMqtt.hdfs.idleTimeout= 60

a1.sinks.sinkMqtt.hdfs.useLocalTimeStamp = true

# Use a channel which buffers events in memory
a1.channels.channelMqtt.type = memory
a1.channels.channelMqtt.capacity = 1000
a1.channels.channelMqtt.transactionCapacity = 100

# Bind the source and sink to the channel
a1.sources.sourceMqtt.channels = channelMqtt
a1.sinks.sinkMqtt.channel = channelMqtt

  bin/flume-ng agent --conf-file  conf/flume-hdfs.properties -c conf/ --name a1 -Dflume.root.logger=DEBUG,console

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值