flume采集日志文件的问题

使用flume1.9.0采集滚动日志,配置:

ag1.sources = s1
ag1.channels = c1
ag1.sinks = k1

ag1.sources.s1.type=exec
ag1.sources.s1.command=tail -F "/home/flume/logtest/logtest-20190518.log"


ag1.channels.c1.type=memory
ag1.channels.c1.capacity=10000
ag1.channels.c1.transactionCapacity=1000

#设置Kafka接收器
ag1.sinks.k1.type=org.apache.flume.sink.kafka.KafkaSink
#设置Kafka的broker地址和端口号
ag1.sinks.k1.brokerList=42.0.12.100:9092
#设置Kafka的Topic
ag1.sinks.k1.topic=TP_logGen
#设置序列化方式
ag1.sinks.k1.serializer.class=kafka.serializer.StringEncoder


ag1.sinks.k1.channel=c1
ag1.sources.s1.channels=c1

 

启动后,日志在滚动,但是都没采集到。

 

修改了下flume任务的配置:

 

ag1.sources = s1
ag1.channels = c1
ag1.sinks = k1

ag1.sources.s1.type=exec
ag1.sources.s1.command=sh /home/flume/a.sh


ag1.channels.c1.type=memory
ag1.channels.c1.capacity=10000
ag1.channels.c1.transactionCapacity=1000

#设置Kafka接收器
ag1.sinks.k1.type=org.apache.flume.sink.kafka.KafkaSink
#设置Kafka的broker地址和端口号
ag1.sinks.k1.brokerList=42.0.12.100:9092
#设置Kafka的Topic
ag1.sinks.k1.topic=TP_logGen
#设置序列化方式
ag1.sinks.k1.serializer.class=kafka.serializer.StringEncoder


ag1.sinks.k1.channel=c1
ag1.sources.s1.channels=c1

 

即将执行的命令修改成执行一个shell脚本

a.sh如下

[flume@study conf]$ cat /home/flume/a.sh
#!/bin/sh

tail -F "/home/flume/logtest/logtest-20190518.log"

 

重启agent,就可以搜集到日志了

 

你可能感兴趣的:(大数据)