flume學習(二)---source

  本文根據flume官網提供的Flume 1.8.0 User Guide整理得出的,主要包括flume1.8.0支持的各類source(以下表)及其說明。html

  碼一個網址:http://blog.csdn.net/accountwcx/article/details/49121663java

source類別 type 數據來源 可靠性 說明
Avro Source avro external Avro client streams    
Thrift Source thrift external Thrift client streams    
Exec Source exec Unix command

不可靠apache

該命令必須可以連續地在標準輸出(控制檯)產生數據,如cat、tail -f等。反例:date異步

注意:對於Exec Source或者其餘異步source,當flume接收數據失敗時沒法告知寫入方接收數據失敗。tcp

(舉例:當Exec Source執行的命令是tail -f log.txt時,其中log.txt是某個應用的日誌文件,該應用會持續不斷地寫入日誌文件。假設flume agent中的channel已經被寫滿,此時再有數據產生,flume已經沒法處理,但flume沒法告知該應用數據接收失敗。所以,這部分數據就沒法經過flume管道繼續向下傳輸,即產生了數據丟失。)ide

JMS Source  jms

JMS destination測試

such as a queue or topic ui

 

 能夠使用任何JMS提供方,但只能使用ActiveMQ測試spa

Spooling Directory Source spooldir 磁盤上的某一具體目錄 

可靠.net

 監測該目錄中的文件變化並讀取變更內容。

亮點:Spooling Directory Source是可靠的,即便flume進程被重啓或者中止也不會丟失數據。

爲了保證Spooling Directory Source的可靠性,其監測的目錄必須遵循如下兩條原則:

1.將某個文件移動到該目錄後,不能再被寫入內容;

2.該目錄下每一個文件的名稱必須是惟一的,包括已經被flume處理的文件。

當該目錄下某個文件被寫入內容或者發生文件名衝突時,flume會輸出錯誤信息並中止flume進程。

 Talidir Source  TAILDIR  文件組合(多個文件)

可靠

工做方式:近實時地監測各個文件,當某個文件有新行寫入時,待文件寫入完成,flume會讀取新寫入的行。

Twitter 1% firehose Source(實驗性)

 org.apache.flume.source.twitter.TwitterSource

   

Experimental source that connects via Streaming API to the 1% sample twitter firehose,continously downloads tweets, converts them to Avro format and sends Avro events to a downstream Flume sink.

注意:這個source是實驗性提供,在flume的每一個小版本中均可能變更,在應用時請留意版本並考察其穩定性。

 Kafka Source

 org.apache.flume.source.kafka.KafkaSource

 Kafka topics    
 NetCat TCP Source  netcat  某個TCP端口接收到的數據    工做方式:監聽某個TCP端口,將每行數據都轉換成一個event並進行傳輸。
NetCat UDP Source netcatudp 某個UDP端口接收到的數據   工做方式:監聽某個UDP端口,將每行數據都轉換成一個event並進行傳輸。
Sequence Generator Source seq 本身生成  

工做方式:一個簡單的序列生成器(由0到totalEvents,步進值爲1,默認的totalEvents是java Long型數據的最大值)。主要用於測試。

注意:當沒法向channel發送event時,本source會從新嘗試發送。

Syslog TCP Source syslogtcp 單個TCP端口產生的系統日誌  

這三個source同屬於Syslog Sources,工做方式都相似:

工做方式:Reads syslog data and generate Flume events.The UDP source treats an entire message as a single event. The TCP sources create a new event for each string of characters separated by a newline (‘n’).

Multiport Syslog TCP Source multiport_syslogtcp 多個TCP端口產生的系統日誌  
Syslog UDP Source syslogudp 單個UDP端口產生的系統日誌  
HTTP Source http

經過HTTP POST/GET

發送的event數據

 

注意:1.GET方式是實驗性的

   2.HTTP requests are converted into flume events by a     pluggable 「handler」 which must implement the                      HTTPSourceHandler interface.

Stress Source

org.apache.flume.source.StressSource

本身生成  

內部負載生成source,主要用於壓力測試,能夠配置event的負載大小。

Avro Legacy Source

org.apache.flume.source.avroLegacy.AvroLegacySource

Flume 0.9.4 agents  

這兩個source同屬於一個大類:Legacy Sources,負責接收Flume 0.9.4 agents發送的events並轉換成Flume 1.0 format,而後存儲在指定的channel中。

Thirft Legacy Source

org.apache.flume.source.thriftLegacy.ThriftLegacySource

 
Custom Source 自定義的FQCN 自定義  

A custom source is your own implementation of the Source interface. A custom source’s class and its dependencies must be included in the agent’s classpath when starting the Flume agent.

The type of the custom source is its FQCN.

Scribe Source

org.apache.flume.source.scribe.ScribeSource

外部的scribe客戶端  

Scribe is another type of ingest system. To adopt existing Scribe ingest system, Flume should use ScribeSource based on Thrift with compatible transfering protocol. For deployment of Scribe please follow the guide from Facebook.(scribe是Facebook公司開發的,因此須要結合Facebook提供的文檔進行開發)

相關文章
相關標籤/搜索