【Flume】flume 容錯環境的搭建 failover

來源:互聯網
上載者:User

標籤:flume

關於failover網上也有很多例子,但是看到的有多重做法,個人覺得,本著職責單一的原則

1、一台機子運行一個flume agent

2、一個agent 的下遊sink指向一個flume agent,不要一個flume agent配置多個連接埠【影響效能】

3、分機子配置,可以避免一台機子司機,另一個仍可以使用,否則陪在一台機子上通過連接埠區分,一旦死機,全盤崩潰


下面看具體執行個體:

首先是flumet agent client的配置

priority越高,優先順序越高,會優先使用該sink

# Name the components on this agenta1.sources = r1a1.sinks = k1 k2a1.channels = c1 # Describe/configure the sourcea1.sources.r1.type = execa1.sources.r1.channels=c1a1.sources.r1.command=tail -F /root/dev/biz/logs/bizlogic.log#define sinkgroupsa1.sinkgroups=g1a1.sinkgroups.g1.sinks=k1 k2a1.sinkgroups.g1.processor.type=failovera1.sinkgroups.g1.processor.priority.k1=10a1.sinkgroups.g1.processor.priority.k2=5a1.sinkgroups.g1.processor.maxpenalty=10000#define the sink 1a1.sinks.k1.type=avroa1.sinks.k1.hostname=192.168.11.179a1.sinks.k1.port=9876#define the sink 2a1.sinks.k2.type=avroa1.sinks.k2.hostname=192.168.11.178a1.sinks.k2.port=9876# Use a channel which buffers events in memorya1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100# Bind the source and sink to the channela1.sources.r1.channels = c1a1.sinks.k1.channel = c1a1.sinks.k2.channel=c1
這裡可以看到使用了sinkgroup,其中包括了兩個sink,兩個sink分別指向不同的flume agent

再來看flume agent server的配置,即179,178的配置,看一個即可


# Name the components on this agenta1.sources = r1a1.sinks = k1a1.channels = c1 # Describe/configure the sourcea1.sources.r1.type=avro#any address to listena1.sources.r1.bind=0.0.0.0a1.sources.r1.port=9876a1.sources.r1.channels=c1# Describe the sinka1.sinks.k1.type = file_rolla1.sinks.k1.sink.directory=/root/dev/flumeout/filea1.sinks.k1.sink.rollInterval=3600# Use a channel which buffers events in memorya1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100# Bind the source and sink to the channela1.sources.r1.channels = c1a1.sinks.k1.channel = c1

可以看出flume agent client和server之間是通過avro來傳輸資料的,avro是flume內建的協議,非常方便,可以將flume整個串起來

下面先啟動flume agent server,再啟動flume agent client

測試如下:

for i in {1..100};do echo "exec test tail -f $i  on terminator 176" >> bizlogic.log;echo $i;sleep 0.1;done
往檔案中寫內容,觸發flume agent client的tail -F,這樣內容就會通過flume agent client 到memory channel中,在通過failover機制選擇優先順序高的sink去輸出,最終輸出的地方,有最後一環的flume配置中sink.type決定,可以看出是file_roll,也就是檔案形式寫到磁碟上,會按照一定方式滾動


起初啟動的時候,178和179都會產生此檔案,但是當你開始產生檔案內容的時候,也還有179才會寫入檔案內容了


至此,完整的flume failover 機制就走通了,共勉!



【Flume】flume 容錯環境的搭建 failover

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.