分享

flume-ng 多节点集群示例


问题导读


1.如何实现agent到collect的连接,并能向collect发送日志?
2.agent,collect是如何配置的?







假设:现有两台机子,命名为:agent,collect。agent IP地址为:192.168.150.137,collect为192.168.150.135
要求:实现agent到collect的连接,并能向collect发送日志。
步骤:
    #name the  components on this agent
    a1.sources  = r1
    a1.sinks =  k1
    a1.channels  = c1
   #  Describe/configure the source
    a1.sources.r1.type  = netcat //这里的数据源设置成netcat,后面将通过telnet传送信息
    a1.sources.r1.bind  = 0.0.0.0 //建议  
    a1.sources.r1.port  = 44444
    # Describe  the sink
    a1.sinks.k1.type  =avro
    a1.sinks.k1.hostname=192.168.150.135  //collect 的IP地址,注意
    a1.sinks.k1.port=60000 //这里的接口要与collect source的接口一致。
# 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。
3.下面设置collect,同agent,新建test.conf 文件
# Name the  components on this agent
a1.sources  = r1
a1.sinks =  k1
a1.channels  = c1
#  Describe/configure the source
a1.sources.r1.type  = avro
a1.sources.r1.bind  = 192.168.150.135 //绑定本机的IP的地址
a1.sources.r1.port  =60000 //接口要与agent sink的port一致
# 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

4.设置好之后保存退出,输入命令:(当前目录为$FLUME_HOME/conf)
flume-ng agent -n a1 -c conf -f test.conf,若没有问题在agent机上输入命令:
flume-ng  agent -c conf -f test.conf -n a1 -Dflume.root.logger=INFO,console
collect机上会出现:
1.png
则表示没有问题。
进入下一步
5.在agent另开一个 terminal,输入 telnet 127.0.0.1 44444 后(需要安装,yum install telnet)
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
然后就可以输入如:ss,enter后到collect机上查看

2.jpg


已有(7)人评论

跳转到指定楼层
Data 发表于 2014-12-26 11:46:50
回复

使用道具 举报

chuyuan_zhou 发表于 2014-12-26 15:48:19
飘过,学习学习!
回复

使用道具 举报

cdb521007 发表于 2015-7-26 13:55:43
貌似懂了一点,感谢版主的分享!!!!
回复

使用道具 举报

小伙425 发表于 2015-9-25 12:29:21
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条