Flume安裝啟動,入門案例

2021-10-24 02:28:45 字數 2197 閱讀 5531

1,上傳解壓

tar -zxvf apache-flume-1.9.0-bin.tar.gz -c ./
ok,完成,解壓即用

2,啟動

根據資料採集的需求配置採集方案,描述在配置檔案中(檔名可任意自定義)

啟動命令示例:

bin/flume-ng agent -c conf -f agentconf/taildir-m-hdfs.conf -n a1
開啟內建監控功能:

-dflume.monitoring.type=http -dflume.monitoring.port=34545
taildir source + memory channel + hdfs sink1,模擬測試日誌檔案指令碼

while true; do echo 111111111111111111111111_$random >> ./eventlog/access.log; sleep 0.2; done
日誌位置:

2,配置檔案

位置:/opt2/taildir-m-hdfs.conf

a1.sources = r1

a1.channels = c1

a1.sinks = k1

# source config

a1.sources.r1.channels = c1

a1.sources.r1.type = taildir

a1.sources.r1.filegroups = g1

a1.sources.r1.filegroups.g1 = /opt2/eventlog/access.*

a1.sources.r1.header.g1.abc = bbb

a1.sources.r1.batchsize = 100

a1.sources.r1.fileheader = true

a1.sources.r1.fileheaderkey = filename

a1.sources.r1.interceptors = i1

a1.sources.r1.interceptors.i1.type = timestamp

# channel config

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactioncapacity = 200

# sink config

a1.sinks.k1.channel = c1

a1.sinks.k1.type = hdfs

a1.sinks.k1.hdfs.path = hdfs://linux01:9000/flume_test/%y-%m-%d/%h-%m/

a1.sinks.k1.hdfs.fileprefix = event_

a1.sinks.k1.hdfs.filesuffix = .log

a1.sinks.k1.hdfs.rollinterval = 0

a1.sinks.k1.hdfs.rollcount = 0

a1.sinks.k1.hdfs.rollsize = 134217728

a1.sinks.k1.hdfs.round = true

a1.sinks.k1.hdfs.roundvalue = 10

a1.sinks.k1.hdfs.roundunit = minute

a1.sinks.k1.hdfs.filetype = datastream

3,啟動

bin/flume-ng agent -c conf -f /opt2/taildir-m-hdfs.conf -n a1
設定輸出日誌等級啟動

bin/flume-ng agent -c conf -f /opt2/taildir-m-hdfs.conf -n a1 -dflume.root.logger=info,console
4,檢視結果

Flume 入門案例

案例需求 使用 flume 監聽乙個埠,收集該埠資料,並列印到控制台。安裝 netcat 工具 判斷 44444 埠是否被占用 sudo netstat nlp grep 44444在 flume 目錄下建立 job 資料夾並進入 job 資料夾。mkdir job cd job在 job 資料夾下...

Flume 入門案例1

監控埠資料官方案例 1 案例需求 使用 flume 監聽乙個埠,收集該埠資料,並列印到控制台。2 需求分析 在這裡插入描述 3 實現步驟 1.安裝 netcat 工具 yum install y nc2.判斷 44444 埠是否被占用 netstat tunlp grep 444443.建立 flu...

flume採集案例

1 採集目錄到hdfs 採集需求 某伺服器的某特定目錄下,會不斷產生新的檔案,每當有新檔案出現,就需要把檔案採集到hdfs中去 根據需求,首先定義以下3大要素 採集源,即source 監控檔案目錄 spooldir 下沉目標,即sink hdfs檔案系統 hdfs sink source和sink之...