日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Flume案例:模拟两个agent之间传递消息的场景

發布時間:2024/9/27 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Flume案例:模拟两个agent之间传递消息的场景 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

模擬兩個agent之間傳遞消息的場景

說明:

1.在hadoop1機器上有一個flume agent,通過exec監聽tail命令輸出的結果。
2.新增的結果通過avro sink的方式下層到hadoop2:4141的avro source端。
3.在hadoop2機器上有一個flume agent,通過avro source來接收下沉過來的數據。

編寫hadoop1上的通信配置文件

在hadoop1上的flume通信控制的文件tail-avro.conf的內容如下:

#Name the components on this agent a1.sources = r1 a1.sinks = k1 a1.channels = c1# Describe/configure the source a1.sources.r1.type = exec a1.sources.r1.command = tail -F /home/tuzq/software/flumedata/test.log a1.sources.r1.channels = c1# Describe the sink ##sink端的avro是一個數據發送者 a1.sinks = k1 ##type設置成avro來設置發消息 a1.sinks.k1.type = avro a1.sinks.k1.channel = c1 ##下沉到hadoop2這臺機器 a1.sinks.k1.hostname = hadoop2 ##下沉到mini2中的4141 a1.sinks.k1.port = 4141 a1.sinks.k1.batch-size = 2# 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

編寫hadoop2上的通信配置文件

在hadoop2上的flume通信控制的文件avro-logger.conf的內容如下:

# Name the components on this agent a1.sources = r1 a1.sinks = k1 a1.channels = c1# Describe/configure the source ##source中的avro組件是一個接收者服務 a1.sources.r1.type = avro a1.sources.r1.channels = c1 a1.sources.r1.bind = 0.0.0.0 a1.sources.r1.port = 4141# 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

執行命令,開始測試

進入hadoop1,模擬test.log文件

[root@hadoop1 flumedata]# cd /home/tuzq/software/flumedata [root@hadoop1 flumedata]# while true > do > date >> test.log > sleep 2 > done

tail命令查看一下test.log

[root@hadoop1 flumedata]# cd /home/tuzq/software/flumedata [root@hadoop1 flumedata]# tail -f test.log 2017年 06月 14日 星期三 10:21:23 CST 2017年 06月 14日 星期三 10:21:25 CST 2017年 06月 14日 星期三 10:21:27 CST 2017年 06月 14日 星期三 10:21:29 CST 2017年 06月 14日 星期三 10:21:31 CST 2017年 06月 14日 星期三 10:21:33 CST 2017年 06月 14日 星期三 10:21:35 CST 2017年 06月 14日 星期三 10:21:37 CST 2017年 06月 14日 星期三 10:21:39 CST 2017年 06月 14日 星期三 10:21:41 CST 2017年 06月 14日 星期三 10:21:43 CST

啟動hadoop2上的flume agent

由于hadoop1上的agent配置文件中配置下沉的位置是hadoop2:4141,所以需要先啟動hadoop2上的flume agent
啟動命令是:

[root@hadoop2 apache-flume-1.6.0-bin]# pwd /home/tuzq/software/apache-flume-1.6.0-bin [root@hadoop2 apache-flume-1.6.0-bin]# ls agentconf bin CHANGELOG conf DEVNOTES docs lib LICENSE NOTICE README RELEASE-NOTES tools [root@hadoop2 apache-flume-1.6.0-bin]# cd agentconf/ [root@hadoop2 agentconf]# ls avro-logger.conf [root@hadoop2 agentconf]# [root@hadoop2 apache-flume-1.6.0-bin]# bin/flume-ng agent -c conf -f agentconf/avro-logger.conf -n a1 -Dflume.root.logger=INFO,console

啟動效果圖如下:

啟動hadoop1上的flume agent

[root@hadoop1 agentconf]# bin/flume-ng agent -c conf -f agentconf/tail-avro.conf -n a1 -Dflume.root.logger=INFO,console

啟動信息:

查看hadoop2上的運行效果

通過上圖發現只要test.log中有日志文件變化,在hadoop2上的agent就會有響應結果

總結

以上是生活随笔為你收集整理的Flume案例:模拟两个agent之间传递消息的场景的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。