黑猴子的家 Flume案例 監控資料夾

2021-08-30 08:50:39 字數 1959 閱讀 9127

使用flume監聽整個目錄的檔案

1、建立配置檔案flume-dir.conf

a3.sources = r3

a3.sinks = k3

a3.channels = c3

# describe/configure the source

a3.sources.r3.type = spooldir

a3.sources.r3.spooldir = /opt/module/flume/upload

# 上傳成功後的新增字尾,防止重複上傳

a3.sources.r3.filesuffix = .completed

a3.sources.r3.fileheader = true

#忽略所有以.tmp結尾的檔案,不上傳

a3.sources.r3.ignorepattern = ([^ ]*\.tmp)

# describe the sink

a3.sinks.k3.type = hdfs

a3.sinks.k3.hdfs.path = hdfs://hadoop102:9000/flume/upload/%y%m%d/%h

#上傳檔案的字首

a3.sinks.k3.hdfs.fileprefix = upload-

#是否按照時間滾動資料夾

a3.sinks.k3.hdfs.round = true

#多少時間單位建立乙個新的資料夾

a3.sinks.k3.hdfs.roundvalue = 1

#重新定義時間單位

a3.sinks.k3.hdfs.roundunit = hour

#是否使用本地時間戳

a3.sinks.k3.hdfs.uselocaltimestamp = true

#積攢多少個event才flush到hdfs一次

a3.sinks.k3.hdfs.batchsize = 100

#設定檔案型別,可支援壓縮

a3.sinks.k3.hdfs.filetype = datastream

#多久生成乙個新的檔案

a3.sinks.k3.hdfs.rollinterval = 600

#設定每個檔案的滾動大小大概是128m

a3.sinks.k3.hdfs.rollsize = 134217700

#檔案的滾動與event數量無關

a3.sinks.k3.hdfs.rollcount = 0

#最小冗餘數

a3.sinks.k3.hdfs.minblockreplicas = 1

# use a channel which buffers events in memory

a3.channels.c3.type = memory

a3.channels.c3.capacity = 1000

a3.channels.c3.transactioncapacity = 100

# bind the source and sink to the channel

a3.sources.r3.channels = c3

a3.sinks.k3.channel = c3

2、執行測試

執行如下指令碼後,請向upload資料夾中新增檔案試試

[victor@hadoop102 flume]$ bin/flume-ng agent --conf conf/ --name a3 --conf-file job/flume-dir.conf
在使用spooling directory source時

1) 不要在監控目錄中建立並持續修改檔案

2) 上傳完成的檔案會以.completed結尾

3) 被監控資料夾每600毫秒掃瞄一次檔案變動

黑猴子的家 Flume簡介

flume 作為 cloudera 開發的實時日誌收集系統,受到了業界的認可與廣泛應用。flume 初始的發行版本目前被統稱為 flume og original generation 屬於 cloudera。但隨著 flume 功能的擴充套件,flume og 工程臃腫 核心元件設計不合理 核心配...

黑猴子的家 Hadoop Checkpoint機制

fsimage和edit log合併的過程如下圖所示 其實這個合併過程是乙個很耗i o與cpu的操作,並且在進行合併的過程中肯定也會有其他應用繼續訪問和修改hdfs檔案。所以,這個過程一般不是在單一的namenode節點上進行從。如果hdfs沒有做ha的話,checkpoint由secondname...

黑猴子的家 FileInputFormat切片機制

1 job提交流程原始碼詳解 waitforcompletion submit 1 建立連線 connect 1 建立提交job的 new cluster getconfiguration 2 判斷是本地yarn還是遠端 initialize jobtrackaddr,conf 2 提交job su...