Flume 操作示例

一、案例1之 Spool

Spool 监测配置的目录下新增的文件,并将文件中的数据读取出来。需要注意两点:

  • 拷贝到 spool 目录下的文件不可以再打开编辑。

  • spool 目录下不可包含相应的子目录。

配置文件

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

a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = /opt/apache-flume-1.6.0-bin/logs
a1.sources.r1.fileHeader = true
a1.sources.r1.channels = c1

a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1

启动命令

bin/flume-ng agent \
    -c conf \
    -f jobs/spool.conf \
    -n a1 \
    -Dflume.root.logger=INFO,console

测试

$ echo "hello world" > logs/spool.log

$ more logs/spool.log.COMPLETED

hello world

233

猜你喜欢

转载自www.cnblogs.com/lemos/p/13173953.html