Flume把命令执行结果写入平面文件

1.创建agent配置文件
把下列内容存入agent2.conf,并保存到Flume的工作目录/opt/flume/bin下面

agent2.sources = execsource
agent2.sinks = filesink
agent2.channels = filechannel

agent2.sources.execsource.type = exec
agent2.sources.execsource.command = cat /opt/flume/testmessage

agent2.sinks.filesink.type = FILE_ROLL
agent2.sinks.filesink.sink.directory = /opt/flume/files
agent2.sinks.filesink.sink.rollInterval = 0

agent2.channels.filechannel.type = file
agent2.channels.filechannel.checkpointDir = /opt/flume/filechannel/checkpoint
agent2.channels.filechannel.dataDirs= /opt/flume/filechannel/data

agent2.sources.execsource.channels = filechannel
agent2.sinks.filesink.channel = filechannel


2.在/opt/flume/下面创建测试文件
caiyong@caiyong:/opt/flume$ echo "Hello,this is a flume test." > /opt/flume/testmessage

3.启动代理
caiyong@caiyong:/opt/flume$ mkdir files
caiyong@caiyong:/opt/flume$ cd bin/
caiyong@caiyong:/opt/flume/bin$ flume-ng agent --conf conf --conf-file agent2.conf --name agent2

4.查看结果
caiyong@caiyong:/opt/flume$ cd files/
caiyong@caiyong:/opt/flume/files$ ls
1426312094333-1
caiyong@caiyong:/opt/flume/files$ cat *
Hello,this is a flume test.

再次执行第三部操作后的结果:
caiyong@caiyong:/opt/flume/files$ cat *
Hello,this is a flume test.
Hello,this is a flume test.

caiyong@caiyong:/opt/flume/files$ ls
1426312094333-1  1426312234005-1



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值