flume的source channel sink官網文檔很豐富,有什麼配置項不清晰直接參考官網文檔。文檔裡面的粗體項是指必須配置的項。參考:Flume Sources
source
1.Spooling Directory Source.監控某個目錄的source。監控到的檔案會重命名成.COMPLETED,監控目錄中如果有檔案不是COMPLETED結尾的,source都會采集,包括監控目錄曆史的資料。重命名的字尾是可配置的。啟動flume agent程序的使用者要對監控的檔案夾有讀寫權限,否則會報錯,監控不了。但是裡面的檔案隻需要有讀的權限就可以了。
sink
1.HDFS Sink.将channel中的資料輸出到hdfs目錄,主意屬性hdfs.fileType,如果沒有配置輸出的資料是亂碼的,要改成DataStream,我們看起來才不會亂碼。參考:Flume采集資料到HDFS時,生成的檔案中,開頭資訊有亂碼
一個source對應多個channel,sink的情形,一個channel隻能發送到一個sink中,參考:Flume一個資料源對應多個channel,多個sink
配置案例如下:
stbagent.sources = stbs1 stbagent.channels = stbc1 stbc2 stbagent.sinks = stbk1 kafkasink # sources stbagent.sources.stbs1.type = spooldir stbagent.sources.stbs1.spoolDir = /tmp/flume-monitor-dir stbagent.sources.stbs1.channels = stbc1 stbc2 # channels stbagent.channels.stbc1.type = memory stbagent.channels.stbc2.type = memory # sinks stbagent.sinks.stbk1.type = hdfs stbagent.sinks.stbk1.hdfs.path = /tmp/flume-monitor-dir stbagent.sinks.stbk1.hdfs.fileType = DataStream stbagent.sinks.stbk1.channel = stbc1 stbagent.sinks.kafkasink.type = org.apache.flume.sink.kafka.KafkaSink stbagent.sinks.kafkasink.brokerList = 192.168.1.11:9092,192.168.1.12:9092,192.168.1.13:9092 stbagent.sinks.kafkasink.topic = flume-topic stbagent.sinks.kafkasink.channel = stbc2 |
版權聲明:本文為CSDN部落客「weixin_34112030」的原創文章,遵循CC 4.0 BY-SA版權協定,轉載請附上原文出處連結及本聲明。
原文連結:https://blog.csdn.net/weixin_34112030/article/details/91584341