flume安装
1、要求将flume日志采集系统部署到需要监控的容器(Tomcat)所在的linux服务器上。 2、将apache-flume-1.7.0-bin.tar.gz文件复制到/home目录下。
3、执行解压命令 tar -zxvf /home/apache-flume-1.7.0-bin.tar.gz 4、执行cd命令cd apache-flume-1.7.0-bin
5、创建flume-env.sh文件命令:cp conf/flume-env.sh.template conf/flume-env.sh
6、创建flume.conf配置文件命令:cp conf/flume-conf.properties.template conf/flume.conf
7、修改flume.conf配置文件内容,在配置文件最下面追加以下配置信息,其中红色部分为tomcat业务日志路径 和influxdb服务器ip地址端口号 agent.channels.memoryChannel.capacity = 500
# Define a memory channel called ch1 on agent1 agent1.channels.ch1.type = memory
# Define an Avro source called avro-source1 on agent1 and tell it # to bind to 0.0.0.0:41414. Connect it to channel ch1. agent1.sources.r1.channels = ch1
agent1.sources.r1.dir = /home/logs/tomcat-2019-04-18.out agent1.sources.r1.type = com.harderxin.flume.test.MySource
# Define a logger sink that simply logs all events it receives # and connect it to the other end of the same channel. agent1.sinks.k1.channel = ch1
agent1.sinks.k1.influxdb = 192.168.5.154:18086
agent1.sinks.k1.type = com.harderxin.flume.test.MySinks
# Finally, now that we've defined all of our components, tell # agent1 which ones we want to activate. agent1.channels = ch1 agent1.sources = r1 agent1.sinks = k1
8、将flumesink.jar文件复制到/home/apache-flume-1.7.0-bin/lib目录下面。 9、启动flume命令:
>cd /home/apache-flume-1.7.0-bin
>nohup bin/flume-ng agent -n agent1 -c conf -f conf/flume.conf -Dflume.root.logger=INFO,console -Duser.timezone=Asia/Shanghai 2>&1 | rotatelogs
/home/apache-flume-1.7.0-bin/logs/flume-%Y-%m-%d-%H.out 3600 480 &
10、复制stopFlume.sh到/home/apache-flume-1.7.0-bin下,停止flume命令: > cd /home/apache-flume-1.7.0-bin > chmod 777 stopFlume.sh > ./stopFlume.sh