flume-ng 多節點集羣示例



假設:現有兩臺機子,命名爲:agent,collect。
agent IP地址爲:192.168.150.137,
collect爲192.168.150.135
要求:實現agent到collect的連接,並能向collect發送日誌。
步驟:
  • 兩臺電腦上分別裝上 jdk,flume-ng(不是flume-og),配置好profile。
  • agent的處理
      (1)找到flume-ng安裝目錄下的conf文件夾,新建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  = 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機上會出現:

則表示沒有問題。
進入下一步
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機上查看
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章