配置

上传example.conf到conf目录下

  1. # example.conf: A single-node Flume configuration
  2. # Name the components on this agent
  3. a1.sources = r1
  4. a1.sinks = k1
  5. a1.channels = c1
  6. # Describe/configure the source
  7. a1.sources.r1.type = netcat
  8. a1.sources.r1.bind = 0.0.0.0
  9. a1.sources.r1.port = 44444
  10. # Describe the sink
  11. a1.sinks.k1.type = logger
  12. # Use a channel which buffers events in memory
  13. a1.channels.c1.type = memory
  14. a1.channels.c1.capacity = 1000
  15. a1.channels.c1.transactionCapacity = 100
  16. # Bind the source and sink to the channel
  17. a1.sources.r1.channels = c1
  18. a1.sinks.k1.channel = c1

image.png

这个配置文件定义了一个Agent叫做a1,a1有一个source监听本机44444端口上接收到的数据、一个缓冲数据的channel还有一个把Event数据输出到控制台的sink。这个配置文件给各个组件命名,并且设置了它们的类型和其他属性。通常一个配置文件里面可能有多个Agent,当启动Flume时候通常会传一个Agent名字来做为程序运行的标记。

中文版
https://flume.liyifeng.org/#
image.png

启动Flume

cd /data/soft/apache-flume-1.9.0-bin

#前台方式运行
bin/flume-ng agent --name a1 --conf conf --conf-file conf/example.conf -Dflume.root.logger=INFO,console

#后台方式运行
nohup bin/flume-ng agent --name a1 --conf conf --conf-file conf/example.conf &

jps-m查看Flume进程
image.png

测试

另外开启一个Xshell会话,使用telnet发送消息
会话2:

yum install -y 

telnet localhost 44444

image.png
会话1:
image.png

查看Flume日志

后台方式运行

cd /data/soft/apache-flume-1.9.0-bin/logs

tail -f flume.log

image.png