1.編輯一個配置文件 flume-app.conf 拷貝至fulme的安裝目錄的conf下

1 # The configuration file needs to define the sources, 2 # the channels and the sinks. 3 4 ### define agent 5 a3.sources = r3 6 a3.channels = c3 7 a3.sinks = k3 8 9 10 ### define sources 11 a3.sources.r3.type = spooldir 12 ### 要掃描的文件夾 13 a3.sources.r3.spoolDir = /opt/cdh-5.3.6/flume-1.5.0-cdh5.3.6/spoollogs 14 ### 以.log結尾的文件不掃描 15 a3.sources.r3.ignorePattern = ^(.)*\\.log$ 16 ### 掃描完成的文件加一個后綴 17 a3.sources.r3.fileSuffix = .delete 18 19 ### define channels 20 a3.channels.c3.type = file 21 a3.channels.c3.checkpointDir = /opt/cdh-5.3.6/flume-1.5.0-cdh5.3.6/filechannel/checkpoint 22 a3.channels.c3.dataDirs = /opt/cdh-5.3.6/flume-1.5.0-cdh5.3.6/filechannel/data 23 24 ### define sink 25 a3.sinks.k3.type = hdfs 26 ### 已當天日期在hdfs上創建一個文件夾 27 a3.sinks.k3.hdfs.path = hdfs://hadoop:8020/user/xuyou/flume/splogs/%Y%m%d 28 a3.sinks.k3.hdfs.fileType = DataStream 29 a3.sinks.k3.hdfs.writeFormat = Text 30 a3.sinks.k3.hdfs.batchSize = 10 31 a3.sinks.k3.hdfs.useLocalTimeStamp = true 32 33 34 ### bind the soures and sink to the channel 35 a3.sources.r3.channels = c3 36 a3.sinks.k3.channel = c3
創建 spoollogs 文件夾 准備一些數據 測試 .log結尾的文件是否被掃描到

執行命令
1 bin/flume-ng agent \ 2 -c conf \ 3 -n a3 \ 4 -f conf/flume-app.conf \ 5 -Dflume.root.logger=DEBUG,console

查看文件 .log結尾的文件果然沒有被讀取到 已經讀取的文件也被加上后綴了

在hdfs上自動以當天時間命名生成了一個文件夾

然后測試 是否一直監控這個文件夾
創建一個文件 然后在查詢發現被標記 后綴了 (ps:如果此文件夾是空的 不會在hdfs生成對應的文件)


