使用flume spool的source,当被监控的目录下有文件更新,就会将文件数据发给chanel。
- 创建自定义conf文件
[root@hadoop01 test_conf]# pwd
/usr/local/wyh/apache-flume-1.8.0-bin/test_conf
[root@hadoop01 test_conf]# cat test-spool-logger.conf
myagent.sources=mysource1
myagent.channels=mychannel1
myagent.sinks=mysinks1
myagent.sources.mysource1.channels=mychannel1
myagent.sinks.mysinks1.channel=mychannel1
myagent.sources.mysource1.type=spooldir
#被监控的目录
myagent.sources.mysource1.spoolDir=/usr/local/wyh/test_data/
#被读取过的文件会给文件名加上后缀.COMPLETED
myagent.sources.mysource1.fileSuffix=.COMPLETED
myagent.channels.mychannel1.type=memory
myagent.sinks.mysinks1.type=logger
myagent.sinks.mysinks1.maxBytesToLog=100
- 启动flume agent
[root@hadoop01 test_conf]# flume-ng agent -c /usr/local/wyh/apache-flume-1.8.0-bin/conf -f /usr/local/wyh/apache-flume-1.8.0-bin/test_conf/test-spool-logger.conf -n