前言
由于数据量不是特别大,因此我们在使用Flume的时候没有使用分区,基本上就是在业务端的web server上部署了一个agent,然后输出到hdfs上。
部署
kafka 数据源
可以参考我的另一篇文章,里面讲了我在工作中遇到的定制的kafka source。
tail 数据源
flume ng里面可以使用Exec Source来代替。其实就相当于执行了一个tail -f 的的命令。
Note You can use ExecSource to emulate TailSource from Flume 0.9x (flume og). Just use unix command
tail -F /full/path/to/your/file
. Parameter -F is better in this case than -f as it will also follow file rotation.
示例。
a1.sources = r1
a1.channels = c1
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /var/log/secure
a1.sources.r1.channels = c1
spooldir 数据源
在 /etc/flume/conf 目录创建 f2.conf 文件,内容如下:
agent-1.channels = ch-1
agent-1.sources = src-1
agent-1.channels.ch-1.type = memory
agent-1.sources.src-1.type = spooldir
agent-1.sources.src-1.channels = ch-1
agent-1.sources.src-1.spoolDir = /root/log
agent-1.sources.src-1.fileHeader = tru