Flume案例(3)

1) Spool

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

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

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

  • 创建agent配置文件
  • 缺点:指定文件下不能有重名(kk.log  kk.log. COMPLETED),报错 是的flume死掉

# > vi /home/bigdata/flume/conf/spool.conf

添加以下内容:

a1.sources = r1

a1.sinks = k1

a1.channels = c1

# Describe configure the source

a1.sources.r1.type = spooldir

a1.sources.r1.spoolDir = /home/data/logs

a1.sources.r1.fileHeader = true

# Describe the sink

a1.sinks.k1.type = logger

# Use a channel which buffers events in memory

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1

  • 启动flume agent a1
  • 创建/home/data/logs文件夹
  • # > mkdir / home/data /logs
  • # > flume-ng agent -c . -f /home/bigdata/flume/conf/spool.conf -n a1 -Dflume.root.logger=INFO,console
  • 追加文件到/hadoop/flume/logs目录

# > echo "spool test1" > /home/data/logs/spool_text.log

  • a1的控制台,可以看到以下相关信息:
原文地址:https://www.cnblogs.com/wxk161640207382/p/10862459.html