案例二:监控一个目录下的文件变动,如果目录下有新文件产生,将新文件信息输出到flume日志中
案例说明
source:spooling directory Source 监控指定目录内数据变更
编写脚本
# 给flume采集进程起一个别名 a1
# 定义flume进程中有几个source、sink、channel,>以及每一个source的别名
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# 定义flume进程中source连接到数据源信息
a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = /opt/test
a1.sources.r1.fileHeader = true
a1.sinks.k1.type = logger
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
执行脚本
flume-ng agent -n a1 -f dirToLogger.conf -Dflume.root.logger=INFO,console
在监听的路径中进行新增文件
新创建一个文件,往里加入即可观察到变化
本文来自博客园,作者:jsqup,转载请注明原文链接:https://www.cnblogs.com/jsqup/p/16554647.html

浙公网安备 33010602011771号