flume 整合kafka

來源:互聯網
上載者:User

標籤:led   time   conf   方式   kafka   require   red   cep   char   

 背景:系統的資料量越來越大,日誌不能再簡單的檔案的儲存,如此日誌將會越來越大,也不方便尋找與分析,綜合考慮下使用了flume來收集日誌,收集日誌後向kafka傳遞訊息,下面給出具體的配置

# The configuration file needs to define the sources,# the channels and the sinks.# Sources, channels and sinks are defined per agent,   # in this case called ‘agent‘agent.sources = r1agent.channels = c1agent.sinks = s1# For each one of the sources, the type is definedagent.sources.r1.type = netcatagent.sources.r1.bind = localhostagent.sources.r1.port = 10245agent.sources.r1.charset = UTF-8# The channel can be defined as follows.agent.sources.r1.channels = c1# Each sink‘s type must be definedagent.sinks.s1.type = org.apache.flume.sink.kafka.KafkaSinkagent.sinks.s1.topic = testagent.sinks.s1.brokerList = ip:9092agent.sinks.s1.requiredAcks = 1agent.sinks.s1.batchSize = 20agent.sinks.s1.channel = c1# Each channel‘s type is defined.agent.channels.c1.type = memory# Other config values specific to each type of channel(sink or source)# can be defined as well# In this case, it specifies the capacity of the memory channelagent.channels.c1.capacity = 100

啟動方式:

   bin/flume-ng agent --conf conf --conf-file conf/kafka.conf --name agent -Dflume.root.logger=INFO,console

再啟動之前一定要先啟動kafka,這裡可能會有一個錯誤

  

Caused by: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Batch Expired

這個是因為預設情況下kafka是廣播的localhost,所以如果不是同一個機器需要修改下配置

advertised.listeners=PLAINTEXT://ip:9092把預設的localhost替換成IP地址 重新啟動下就可以了.

flume 整合kafka

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.