关于Flume-ng那些事(二)

air 日志系统关于Flume-ng那些事(二)已关闭评论10,5542字数 1887阅读6分17秒阅读模式

继续我们的测试。

编辑flume.conf配置文件文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/

# 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的完整配置文件需要如下内容:文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/

a,Sources, sources type
b,Sinks ,sinks type
c,Channel ,Channel type
d,使用Channel 来串接Sources和Sinks文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/

我们根据上述的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文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/

—————————我是分割线—————————
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类型。文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/

——————————————————————————————文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/

开始我们的测试:
首先开启客户端:文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/

# flume-ng agent -n agent1 -c /opt/apps/flume-ng/conf/ -f flume.conf  &

#注意名字agent1要和配置文件定义的一致。文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/

开启avro-client客户端读取/etc/passwors 文件:文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/

# flume-ng avro-client -c /opt/apps/flume-ng/conf/ -H localhost -p 41414 -F /etc/passwd

#启动avro-client 读取/etc/passwd 后进程退出。文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/

验证下我们的测试情况,查看flume.log  详见附件flume_log01.txt文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/

文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/文章源自运维生存时间-https://www.ttlsa.com/log-system/about-flume-ng-2/
weinxin
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
air
  • 本文由 发表于 03/09/2013 16:21:12
  • 转载请务必保留本文链接:https://www.ttlsa.com/log-system/about-flume-ng-2/