2.2、复杂数据流
2.2.1、多hop# example.conf: A single-node Flume configuration # Name the components on this agent a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = netcat a1.sources.r1.bind = localhost a1.sources.r1.port = 44444 # 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),a1中有source节点实例(r1),channel通道实例(c1)和sink节点实例(k1)。r1节点从netcat命令获取数据,r1节点与c1通道绑定;k1节点与c1通道绑定,k1节点将数据传递给日志处理框架。
3.2、开始运行执行“bin/flume-ng agent -n a1 -f config.properties -Dflume.root.logger=INFO,console”命令,开始运行"a1"这个Flume Agent。
其中"-n"选项的值表示Flume Agent的实例名称,"-f"选项的值表示配置文件的路径。
此时本机44444端口上的数据会通过该Agent被传递给日志处理框架,由于“-Dflume.root.logger=INFO,console”的设置,日志处理框架直接在控制台打印数据。3)Flume Agent从44444端口上获取数据,将其传递给日志处理框架,这里是直接在控制台中打印
参考文献:
[1]https://flume.apache.org/releases/content/1.6.0/FlumeUserGuide.pdf