# example.conf: A single-node Flume configuration
使用flume的关境就是写配置文件
A)配置source
B)配置channel
C)配置sink
D)把以上3个组件串起来
a1: agent名称
r1:source的名称
k1:sink的名称
c1: channel的名称
# 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
注意 ;串起来
一个source 可以输出到多个channel 但一个sink只能来自一个channel
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
二.把上面内容放conf 下的 example.conf下面
三.启动agent
flume-ng agent --conf $FLUME_HOME/conf --conf-file $FLUME_HOME/conf/example.conf --name a1 -Dflume.root.logger=INFO,console
四.使用telnet 进行测试 telnet localhost 44444
Event: { headers:{} body: 61 73 64 0D asd. }
Event 是flume 的数据传输的基本单元
event= 可选的header + byte array