Flume的使用之二——实时监控文件的数据变化并发送到工作台

来源:互联网 发布:2016奥运男篮冠军数据 编辑:程序博客网 时间:2024/05/18 00:50

1.写配置文件

agent:exec source + memory channel + logger sink


a1.sources = r1
a1.sinks = k1
a1.channels = c1

a1.sources.r1.type = exec #exec source 可以运行一个给定的shell命令
a1.sources.r1.command = tail -F “预监听文件的路径”
a1.sources.r1.shell = /bin/sh -c

a1.sinks.k1.type = logger

a1.channels.c1.type = memory

a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

写入到example2.conf中

2.启动agent

flume-ng agent \
--name a1  \
--conf $FLUME_HOME/conf  \
--conf-file $FLUME_HOME/conf/example2.conf \
-Dflume.root.logger=INFO,console

3.检测

向data.log中写入hello world 

echo hello world >> data.log

控制台输出


成功

阅读全文
0 0
原创粉丝点击