根据资源规划,Flume安装在节点LTSR005(**agent2**)、LTSR006(**agent3**)、LTSR008(**agent1**)上。
解压缩
cd ~/software
tar -zxvf apache-flume-1.6.0-bin.tar.gz -C ~/modules/
cd ~/modules/apache-flume-1.6.0-bin
rm -rf docs/* ##清理doc文档
创建相关目录
cd ~/modules/apache-flume-1.6.0-bin/conf
cp flume-env.sh.template flume-env.sh
cp flume-conf.properties.template flume-conf.properties
配置flume-env.sh
export JAVA_HOME=/home/lonton/modules/jdk1.8.0_221
export JAVA_OPTS="-Xms100m -Xmx200m -Dcom.sun.management.jmxremote"
export HADOOP_HOME=/home/lonton/modules/hadoop-2.5.0
分发
cd ~/modules
scp -r apache-flume-1.6.0-bin lonton@LTSR005:/home/lonton/modules/
scp -r apache-flume-1.6.0-bin lonton@LTSR006:/home/lonton/modules/
配置flume-conf.properties
1.agent2:LTSR005(从文件采集数据)
agent2.sources = r1
agent2.channels = c1
agent2.sinks = k1
# sources
agent2.sources.r1.type = exec
agent2.sources.r1.command = tail -F /home/lonton/modules/weblog-flume.log
agent2.sources.r1.channels = c1
# channels
agent2.channels.c1.type = memory
agent2.channels.c1.capacity = 10000
agent2.channels.c1.transactionCapacity = 10000
agent2.channels.c1.keep-alive = 5
# sinks
agent2.sinks.k1.type = avro
agent2.sinks.k1.channel = c1
agent2.sinks.k1.hostname = LTSR008
agent2.sinks.k1.port = 5555
2.agent3:LTSR006(从文件采集数据)
agent3.sources = r1
agent3.channels = c1
agent3.sinks = k1
# sources
agent3.sources.r1.type = exec
agent3.sources.r1.command = tail -F /home/lonton/modules/weblog-flume.log
agent3.sources.r1.channels = c1
# channels
agent3.channels.c1.type = memory
agent3.channels.c1.capacity = 10000
agent3.channels.c1.transactionCapacity = 10000
agent3.channels.c1.keep-alive = 5
# sinks
agent3.sinks.k1.type = avro
agent3.sinks.k1.channel = c1
agent3.sinks.k1.hostname = LTSR008
agent3.sinks.k1.port = 5555
3.agent1: LTSR008(聚合agent2、agent3,输出到控制台)
agent1.sources = r1
agent1.channels = testC
agent1.sinks = testS
agent1.sources.r1.type = avro
agent1.sources.r1.channels = testC
agent1.sources.r1.bind = LTSR008
agent1.sources.r1.port = 5555
agent1.sources.r1.threads = 5
agent1.channels.testC.type = memory
agent1.channels.testC.capacity = 100000
agent1.channels.testC.transactionCapacity = 100000
agent1.channels.testC.keep-alive = 20
agent1.sinks.testS.channel = testC
agent1.sinks.testS.type = logger
启动Flume
cd ~/modules/apache-flume-1.6.0-bin
bin/flume-ng agent --conf conf -f conf/flume-conf.properties -n agent2 -Dflume.root.logger=INFO,console
bin/flume-ng agent --conf conf -f conf/flume-conf.properties -n agent3 -Dflume.root.logger=INFO,console
bin/flume-ng agent --conf conf -f conf/flume-conf.properties -n agent1 -Dflume.root.logger=INFO,console
验证
追加测试文件数据
cd ~/modules/
for i in {1..105}
> do
> echo "exec tail$i">> weblog-flume.log
> done
读取成功后LTSR008的控制台将可以获取采集数据。