flume的配置詳解

1.flume版本是1.8
關於flume的各個source channel sink選型 注意看看官網http://flume.apache.org/releases/content/1.9.0/FlumeUserGuide.html

source sink 選型。看你是T+1還是實時,是監控目錄還是tail -F 文件。
具體優缺點看這篇博客https://blog.csdn.net/u013384984/article/details/79436078
我這裏選之前選spooldir ,監控目錄一旦目錄中有新文件缺點是一旦監控的目錄中有新的文件可以讀,但這個個文件就不能寫因此做不到準實時。
選用taildir 實時讀,但要注意解決多個小文件問題,這時就要看參數怎麼配置。在hdfs上生成的文件滾動方式設置,我們是按大小滾動,注意其他的滾定方式就要設置爲0。

taildir_logtohdfs.properties


#agent_name
read.sources = r1
read.sinks = k1
read.channels = c1

#source的配置
# source類型
read.sources.r1.type = TAILDIR
# 元數據位置,可以斷點續傳。
read.sources.r1.positionFile = /usr/local/flume-1.8.0/conf/taildir_position.json
# 監控的目錄
read.sources.r1.filegroups = f1
read.sources.r1.filegroups.f1 = /data/logs/read/.*log
read.sources.r1.fileHeader = true

#sink的配置
read.sinks.k1.type = hdfs
read.sinks.k1.hdfs.useLocalTimeStamp = true
#注意這裏最好要加小時,這時就可以H+1入庫,要不然load進庫沒有會報錯。
read.sinks.k1.hdfs.path = hdfs://192.168.1.154:8022/user/read/data/%Y%m%d/%H
read.sinks.k1.hdfs.filePrefix = read_access
read.sinks.k1.hdfs.fileSuffix = .log
read.sinks.k1.hdfs.rollSize = 134217728
read.sinks.k1.hdfs.rollCount = 0
read.sinks.k1.hdfs.rollInterval = 0
read.sinks.k1.hdfs.writeFormat = Text
read.sinks.k1.hdfs.fileType = DataStream
read.sinks.k1.hdfs.idleTimeout = 120
read.sinks.k1.hdfs.minBlockReplicas = 1

#channel的配置
read.channels.c1.type = memory
read.channels.c1.capacity = 100000
read.channels.c1.transactionCapacity = 100000

#用channel鏈接source和sink
read.sources.r1.channels = c1
read.sinks.k1.channel = c1

啓動命令
nohup bin/flume-ng agent -n read -c conf -f /usr/local/flume-1.8.0/conf/taildir_logtohdfs.properties &

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章