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
把下列内容存入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