FLUME主要用的两种配置方法:
1:spooldir - 用来一取某个文件夹下的所有日志。不断生成日志
2:exec - 用来一取一个文件夹下的追加日志。eg-log4j打印日志到aaa.log最后一行
启动命令:bin/flume-ng agent -c conf -f conf/tail-hdfs.conf -n a1
- spooldir 的配置
#定义三大组件的名称
ag1.sources = source1
ag1.sinks = sink1
ag1.channels = channel1
# 配置source组件
ag1.sources.source1.type = spooldir
ag1.sources.source1.spoolDir = /root/log/
ag1.sources.source1.fileSuffix=.FINISHED
ag1.sources.source1.deserializer.maxLineLength=5120
# 配置sink组件
ag1.sinks.sink1.type = hdfs
ag1.sinks.sink1.hdfs.path =hdfs://hdp-01:9000/access_log/%y-%m-%d/%H-%M
ag1.sinks.sink1.hdfs.filePrefix = app_log
ag1.sinks.sink1.hdfs.fileSuffix = .log
ag1.sinks.sink1.hdfs.batchSize= 100
ag1.sinks.sink1.hdfs.fileType = DataStream
ag1.sinks.sink1.hdfs.writeFormat =Text
## roll:滚动切换:控制写文件的切换规则
ag1.sinks.sink1.hdfs.rollSize = 512000 ## 按文件体积(字节)