继续我们的测试。
编辑flume.conf配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Define a memory channel called ch1 on agent1 agent1.channels.ch1.type = memory # Define an Avro source called avro-source1 on agent1 and tell it # to bind to 0.0.0.0:41414. Connect it to channel ch1. agent1.sources.avro–source1.channels = ch1 agent1.sources.avro–source1.type = avro agent1.sources.avro–source1.bind = 0.0.0.0 agent1.sources.avro–source1.port = 41414 # Define a logger sink that simply logs all events it receives # and connect it to the other end of the same channel. agent1.sinks.log–sink1.channel = ch1 agent1.sinks.log–sink1.type = logger # Finally, now that we’ve defined all of our components, tell # agent1 which ones we want to activate. agent1.channels = ch1 agent1.sources = avro–source1 agent1.sinks = log–sink1 |
一个agnet的完整配置文件需要如下内容:
a,Sources, sources type
b,Sinks ,sinks type
c,Channel ,Channel type
d,使用Channel 来串接Sources和Sinks
我们根据上述的flume.conf 文件来做下解释,该配置文件其实应该调整下顺序。
先定义下sources、slinks、channels。flume-ng agent名字为agent1,该名字和后续启动agent程序-n 后的名称要保持一致。
agent1.channels = ch1 #channels 名称 ch1
agent1.sources = avro-source1 #sources 名称 avro-source1 名字能望文生义,不错:)
agent1.sinks = log-sinke1 # sinks 名称为 log-sink1
—————————我是分割线—————————
sources 部分定义
agent1.sources.avro-source1.channels = ch1 #agent名称.sources.sources名称.使用的channels
agent1.sources.avro-source1.type = avro #同上最后一个点.type 类型 avro
agent1.sources.avro-source1.bind = 0.0.0.0 #最后一个点.bind 绑定地址
agent1.sources.avro-source1.port = 41414 #最后一个点.port 指定端口
—————————我是分割线—————————
channel 部分定义:
agent1.channels.ch1.type = memory #agent名称.channels.channels名称.使用的类型
—————————我是分割线—————————
agent1.sinks.log-sink1.channel = ch1 # agent名称.sinks.sinks名称.从哪个channel收集events
agent1.sinks.log-sink1.type = logger #最后一个点.type sinks类型。
——————————————————————————————
开始我们的测试:
首先开启客户端:
1 | # flume-ng agent -n agent1 -c /opt/apps/flume-ng/conf/ -f flume.conf & |
#注意名字agent1要和配置文件定义的一致。
开启avro-client客户端读取/etc/passwors 文件:
1 | # flume-ng avro-client -c /opt/apps/flume-ng/conf/ -H localhost -p 41414 -F /etc/passwd |
#启动avro-client 读取/etc/passwd 后进程退出。
验证下我们的测试情况,查看flume.log 详见附件flume_log01.txt