Flume实战:
Flume的使用关键就是配置文件
A)配置source
B)配置Channel
C)配置SInk
D)把以上三个文件串起来
a1:agent的名称
r1:source的名称
k1: sink的名称
c1: channel的名称
实例:收集端口号为44444的应用日志,并输出到控制台:logger
配置文件(example.conf,从官网获取)
# 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
启动agent:

测试:telnet localhost 44444
localhost为主机名,44444为port
Event: { headers:{} body: 68 65 6C 6C 6F 0D hello. }
Event是Flume的数据传输单元
Event=可选的header+byte array
网友评论