案例四:启动一个采集数据脚本,监听一个文件内容变化,将监听到的文件内容变化输出到flume日志中

说明

数据源:exec,这里命令是tail -F
目的地/下沉地:flume日志

编写脚本

# 给flume采集进程起一个别名 a1
# 定义flume进程中有几个source、sink、channel,以及每一个source的别名
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# 定义flume进程中source连接到数据源信息
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /opt/test/a.txt

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 fileToLogger.conf -Dflume.root.logger=INFO,console

监听数据

[root@node1 test]# pwd
/opt/test
[root@node1 test]# echo "adfa" >> a.txt
posted @ 2022-08-05 17:33  jsqup  阅读(43)  评论(0编辑  收藏  举报