flume

flume配置与启动

官方文档

http://flume.apache.org/

配置flume-conf.properties.template 

agent.sources = seqGenSrc

agent.channels = memoryChannel

agent.sinks = loggerSink



# For each one of the sources, the type is defined

agent.sources.seqGenSrc.type = seq



# The channel can be defined as follows.

agent.sources.seqGenSrc.channels = memoryChannel



# Each sink's type must be defined

agent.sinks.loggerSink.type = logger



#Specify the channel the sink should use

agent.sinks.loggerSink.channel = memoryChannel



# Each channel's type is defined.

agent.channels.memoryChannel.type = memory



agent.channels.memoryChannel.capacity = 100


启动flume 

bin/flume-ng agent -n agent -c conf -f conf/flume-conf.properties.template -Dflume.root.logger=INFO,console

flume集群

示意图

 

设计

服务器

角色

cdh2

监听文件变化

cdh3

监听文件变化

cdh1

显示cdh1和cdh2的变化

 

配置文件

flume-conf-1(cdh2、cdh3)


agent.sources = execSource

agent.channels = memoryChannel

agent.sinks = avroSink



# For each one of the sources, the type is defined

agent.sources.execSource.type = exec

agent.sources.execSource.command = tail -F /root/data/flume/test.log

agent.sources.execSource.channels = memoryChannel





# Each channel's type is defined.

agent.channels.memoryChannel.type = memory

agent.channels.memoryChannel.capacity = 100





# Each sink's type must be defined

agent.sinks.avroSink.type = avro

agent.sinks.avroSink.channel = memoryChannel

agent.sinks.avroSink.hostname = cdh1

agent.sinks.avroSink.port = 1234


flume-conf-2(cdh1) 

agent.sources = avroSource

agent.channels = memoryChannel

agent.sinks = loggerSink



# For each one of the sources, the type is defined

agent.sources.avroSource.type = avro

agent.sources.avroSource.channels = memoryChannel

agent.sources.avroSource.bind = 0.0.0.0

agent.sources.avroSource.port = 1234



# Each channel's type is defined.

agent.channels.memoryChannel.type = memory

agent.channels.memoryChannel.capacity = 100



# Each sink's type must be defined

agent.sinks.loggerSink.type = logger

agent.sinks.loggerSink.channel = memoryChannel


分发flume并创立软连接 

/root/tools/deploy.sh /root/app/apache-flume-1.7.0-bin /root/app/ slave

集群启动

cdh2、cdh3

bin/flume-ng agent -n agent -c conf -f conf/flume-conf-1.properties -Dflume.root.logger=INFO,console

cdh1

bin/flume-ng agent -n agent -c conf -f conf/flume-conf-2.properties -Dflume.root.logger=INFO,console

测试

cdh2

[root@cdh2 flume]# echo "cdh2" >>test.log 

[root@cdh2 flume]# echo "cdh2" >>test.log 

[root@cdh2 flume]# echo "cdh2" >>test.log 

cdh3

[root@cdh3 flume]# echo "cdh3" >>test.log 

[root@cdh3 flume]# echo "cdh3" >>test.log 

[root@cdh3 flume]# echo "cdh3" >>test.log 

cdh1效果

flume与kafka集成

设计

服务器

服务

Source

sink

cdh2

flume

监听文件变化 tail-f

收集的数据落库到cdh1的flume

cdh3

flume

监听文件变化 tail-f

收集的数据落库到cdh1的flume

cdh1

flume

监听cdh2、cdh3发送的数据

收集的数据落库到kafka

 

配置

flume-conf-1(cdh2、cdh3)


agent.sources = execSource

agent.channels = memoryChannel

agent.sinks = avroSink



# For each one of the sources, the type is defined

agent.sources.execSource.type = exec

agent.sources.execSource.command = tail -F /root/data/flume/test.log

agent.sources.execSource.channels = memoryChannel





# Each channel's type is defined.

agent.channels.memoryChannel.type = memory

agent.channels.memoryChannel.capacity = 100





# Each sink's type must be defined

agent.sinks.avroSink.type = avro

agent.sinks.avroSink.channel = memoryChannel

agent.sinks.avroSink.hostname = cdh1

agent.sinks.avroSink.port = 1234


flume-conf-3(cdh1) 

agent.sources = avroSource

agent.channels = memoryChannel

agent.sinks = kafkaSink



# For each one of the sources, the type is defined

agent.sources.avroSource.type = avro

agent.sources.avroSource.channels = memoryChannel

agent.sources.avroSource.bind = 0.0.0.0

agent.sources.avroSource.port = 1234



# Each channel's type is defined.

agent.channels.memoryChannel.type = memory

agent.channels.memoryChannel.capacity = 100



# Each sink's type must be defined

agent.sinks.kafkaSink.type = org.apache.flume.sink.kafka.KafkaSink

agent.sinks.kafkaSink.kafka.topic =  test

agent.sinks.kafkaSink.kafka.bootstrap.servers = cdh1:9092,cdh2:9092,cdh3:9092

agent.sinks.kafkaSink.channel = memoryChannel


cdh2、cdh3 

bin/flume-ng agent -n agent -c conf -f conf/flume-conf-1.properties -Dflume.root.logger=INFO,console

cdh1

bin/flume-ng agent -n agent -c conf -f conf/flume-conf-3.properties -Dflume.root.logger=INFO,console

测试

cdh2

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值