flume-ng 多節點集羣示例

假設:現有兩臺機子,命名爲:agent,collect。agent IP地址爲:192.168.150.137,collect爲192.168.150.135this

要求:實現agent到collect的鏈接,並能向collect發送日誌。spa

步驟:日誌

  1. 兩臺電腦上分別裝上 jdk,flume-ng(不是flume-og),配置好profile。具體參見百度。component

  2. agent的處理  接口

      (1)找到flume-ng安裝目錄下的conf文件夾,新建test.confci

      

    #name the  components on this agentterminal

    a1.sources  = r1it

    a1.sinks =  k1io

    a1.channels  = c1console

   #  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機上查看



剛學Linux 和flume沒幾天,有不足還請指教,多多交流,充分發揮開源中國的做用。

相關文章
相關標籤/搜索