測試將web日誌流檔案寫入hdfs的配置檔案

2021-09-02 07:09:08 字數 2196 閱讀 4163

a1.sources = r1

a1.sinks = k1

a1.channels = c1

a1.sources.r1.type = spooldir

a1.sources.r1.spooldir =/home/hadoop/log

a1.sources.r1.fileheader = true

a1.sinks.k1.type = hdfs

a1.sinks.k1.channel = c1

a1.sinks.k1.hdfs.path = /flume/events/%y-%m-%d/

a1.sinks.k1.hdfs.fileprefix = events-

a1.sinks.k1.hdfs.round = true

a1.sinks.k1.hdfs.roundvalue = 10

a1.sinks.k1.hdfs.roundunit = second

a1.sinks.k1.hdfs.rollinterval = 2

a1.sinks.k1.hdfs.rollsize = 10240

a1.sinks.k1.hdfs.rollcount = 256

a1.sinks.k1.hdfs.batchsize = 50

a1.sinks.k1.hdfs.uselocaltimestamp = true

a1.sinks.k1.hdfs.filetype = datastream

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactioncapacity = 100

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1

是監控資料夾,看一下寫在hdfs之後的樣子,速度很快。

需要注意的是:我監控的是整個資料夾,寫完之後,flume會將這個資料夾的名字在後面加上乙個.complmeted

加上了這個字尾之後,下次就不會監控這個資料夾了。我之前測試的時候,沒注意到這一點,發現一直都沒往hdfs上寫檔案,我還傻傻等半天。

後面我又修改了配置檔案,如果不修改的話,那麼生成太多的檔案,執行mapreduce程式會非常地卡。

a1.sources = r1

a1.sinks = k1

a1.channels = c1

a1.sources.r1.type = spooldir

a1.sources.r1.spooldir =/home/hadoop/log

a1.sources.r1.fileheader = true

a1.sinks.k1.type = hdfs

a1.sinks.k1.channel = c1

a1.sinks.k1.hdfs.path = /flume/events/%y-%m-%d/

a1.sinks.k1.hdfs.fileprefix = events-

a1.sinks.k1.hdfs.round = true

a1.sinks.k1.hdfs.roundvalue = 10

a1.sinks.k1.hdfs.roundunit = second

a1.sinks.k1.hdfs.rollinterval = 3

a1.sinks.k1.hdfs.rollsize = 1048576

a1.sinks.k1.hdfs.rollcount = 0

a1.sinks.k1.hdfs.batchsize = 50

a1.sinks.k1.hdfs.uselocaltimestamp = true

a1.sinks.k1.hdfs.filetype = datastream

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactioncapacity = 100

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1

flask將日誌寫入日誌檔案

import logging logging.basicconfig level logging.debug,控制台列印的日誌級別 filename log new.log 將日誌寫入log new.log檔案中 filemode a 模式,有w和a,w就是寫模式,每次都會重新寫日誌,覆蓋之前的日誌...

logging日誌管理 將日誌寫入檔案

coding cp936 test.py logging日誌管理 將日誌寫入檔案 import logging 建立日誌log檔案,注意是log字尾 log filename loggingtest.log 設定日誌格式 log format filename s asctime s levelna...

logging日誌管理 將日誌寫入檔案

coding cp936 test.py logging日誌管理 將日誌寫入檔案 import logging 建立日誌log檔案,注意是log字尾 log filename loggingtest.log 設定日誌格式 log format filename s asctime s levelna...