详细的flume工程代码见百度网盘:
实现的功能:监听某个文件的最新输入,让后将其输入到制定文件中。
#配置文件:push.conf
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type =spooldir
a1.sources.r1.spoolDir =/home/jurf/testbyljf
a1.sources.r1.fileHeader= true
a1.sources.r1.channels =c1
# Describe the sink
a1.sinks.k1.type = com.ultrapower.plugs.demos.RenameFileNameSink
a1.sinks.k1.file.name=testfu.txt
a1.sinks.k1.file.directory=/home/jurf
a1.sinks.k1.channel = c1
# Use a channel which buffers events inmemory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
执行结果:
从图中可以看出:mylog中的最新内容,实时的通过flume输入到testfu.txt文件中。