根据资源规划,Flume安装在节点LTSR005(**agent2**)、LTSR006(**agent3**)、LTSR008(**agent1**)上。
解压缩
cd ~/softwaretar -zxvf apache-flume-1.6.0-bin.tar.gz -C ~/modules/cd ~/modules/apache-flume-1.6.0-binrm -rf docs/* ##清理doc文档
创建相关目录
cd ~/modules/apache-flume-1.6.0-bin/confcp flume-env.sh.template flume-env.shcp flume-conf.properties.template flume-conf.properties
配置flume-env.sh
export JAVA_HOME=/home/lonton/modules/jdk1.8.0_221export JAVA_OPTS="-Xms100m -Xmx200m -Dcom.sun.management.jmxremote"export HADOOP_HOME=/home/lonton/modules/hadoop-2.5.0
分发
cd ~/modulesscp -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 = r1agent2.channels = c1agent2.sinks = k1# sourcesagent2.sources.r1.type = execagent2.sources.r1.command = tail -F /home/lonton/modules/weblog-flume.logagent2.sources.r1.channels = c1# channelsagent2.channels.c1.type = memoryagent2.channels.c1.capacity = 10000agent2.channels.c1.transactionCapacity = 10000agent2.channels.c1.keep-alive = 5# sinksagent2.sinks.k1.type = avroagent2.sinks.k1.channel = c1agent2.sinks.k1.hostname = LTSR008agent2.sinks.k1.port = 5555
2.agent3:LTSR006(从文件采集数据)
agent3.sources = r1agent3.channels = c1agent3.sinks = k1# sourcesagent3.sources.r1.type = execagent3.sources.r1.command = tail -F /home/lonton/modules/weblog-flume.logagent3.sources.r1.channels = c1# channelsagent3.channels.c1.type = memoryagent3.channels.c1.capacity = 10000agent3.channels.c1.transactionCapacity = 10000agent3.channels.c1.keep-alive = 5# sinksagent3.sinks.k1.type = avroagent3.sinks.k1.channel = c1agent3.sinks.k1.hostname = LTSR008agent3.sinks.k1.port = 5555
3.agent1: LTSR008(聚合agent2、agent3,输出到控制台)
agent1.sources = r1agent1.channels = testCagent1.sinks = testSagent1.sources.r1.type = avroagent1.sources.r1.channels = testCagent1.sources.r1.bind = LTSR008agent1.sources.r1.port = 5555agent1.sources.r1.threads = 5agent1.channels.testC.type = memoryagent1.channels.testC.capacity = 100000agent1.channels.testC.transactionCapacity = 100000agent1.channels.testC.keep-alive = 20agent1.sinks.testS.channel = testCagent1.sinks.testS.type = logger
启动Flume
cd ~/modules/apache-flume-1.6.0-binbin/flume-ng agent --conf conf -f conf/flume-conf.properties -n agent2 -Dflume.root.logger=INFO,consolebin/flume-ng agent --conf conf -f conf/flume-conf.properties -n agent3 -Dflume.root.logger=INFO,consolebin/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的控制台将可以获取采集数据。
