Flume配置文件(跟踪文件夹)

1.将flume-1.6.0 压缩包上传到apps目录下
在这里插入图片描述
2.在apps目录下解压压缩包
tar -zxvf apache-flume-1.6.0-bin.tar.gz
在这里插入图片描述
解压完成

3.在 /apps/apahce-flume-1.6.0-bin/conf目录下对flume进行配置
Flume配置文件(跟踪文件夹)_第1张图片

配置文件内容(dir-hdfs.conf):

pooldir:flume中自带的读取目录的source,只要出现新文件就会被读走
#定义三大组件的名称
ag1.sources = source1
ag1.sinks = sink1
ag1.channels = channel1

# 配置source组件
ag1.sources.source1.type = spooldir    
ag1.sources.source1.spoolDir = /root/log/ 
ag1.sources.source1.fileSuffix=.FINISHED   
ag1.sources.source1.deserializer.maxLineLength=5129  

# 配置sink组件 把读到的文件存放到哪个地方
ag1.sinks.sink1.type = hdfs
ag1.sinks.sink1.hdfs.path =hdfs://hdp-1:9000/access_log/%y-%m-%d/%H-%M
ag1.sinks.sink1.hdfs.filePrefix = app_log
ag1.sinks.sink1.hdfs.fileSuffix = .log
ag1.sinks.sink1.hdfs.batchSize= 100  
ag1.sinks.sink1.hdfs.fileType = DataStream   
ag1.sinks.sink1.hdfs.writeFormat = Text

## roll:滚动切换:控制写文件的切换规则,sink在hdfs中生成文件的时候
ag1.sinks.sink1.hdfs.rollSize = 512000    

ag1.sinks.sink1.hdfs.rollCount = 1000000  
ag1.sinks.sink1.hdfs.rollInterval = 60    

## 控制生成目录的规则    目录多久切一次
ag1.sinks.sink1.hdfs.round = true
ag1.sinks.sink1.hdfs.roundValue = 10    
ag1.sinks.sink1.hdfs.roundUnit = minute   

ag1.sinks.sink1.hdfs.useLocalTimeStamp = true  

# channel组件配置
ag1.channels.channel1.type = memory
ag1.channels.channel1.capacity = 500000  
ag1.channels.channel1.transactionCapacity = 600 

# 绑定source、channel和sink之间的连接
ag1.sources.source1.channels = channel1
ag1.sinks.sink1.channel = channel1#spooldir:flume中自带的读取目录的source,只要出现新文件就会被读走
#定义三大组件的名称
ag1.sources = source1
ag1.sinks = sink1
ag1.channels = channel1

# 配置source组件
ag1.sources.source1.type = spooldir    
ag1.sources.source1.spoolDir = /root/log/ 
ag1.sources.source1.fileSuffix=.FINISHED   
ag1.sources.source1.deserializer.maxLineLength=5129  

# 配置sink组件 把读到的文件存放到哪个地方
ag1.sinks.sink1.type = hdfs
ag1.sinks.sink1.hdfs.path =hdfs://hdp-1:9000/access_log/%y-%m-%d/%H-%M
ag1.sinks.sink1.hdfs.filePrefix = app_log
ag1.sinks.sink1.hdfs.fileSuffix = .log
ag1.sinks.sink1.hdfs.batchSize= 100  
ag1.sinks.sink1.hdfs.fileType = DataStream   
ag1.sinks.sink1.hdfs.writeFormat = Text

## roll:滚动切换:控制写文件的切换规则,sink在hdfs中生成文件的时候
ag1.sinks.sink1.hdfs.rollSize = 512000    

ag1.sinks.sink1.hdfs.rollCount = 1000000  
ag1.sinks.sink1.hdfs.rollInterval = 60    

## 控制生成目录的规则    目录多久切一次
ag1.sinks.sink1.hdfs.round = true
ag1.sinks.sink1.hdfs.roundValue = 10    
ag1.sinks.sink1.hdfs.roundUnit = minute   

ag1.sinks.sink1.hdfs.useLocalTimeStamp = true  

# channel组件配置
ag1.channels.channel1.type = memory
ag1.channels.channel1.capacity = 500000  
ag1.channels.channel1.transactionCapacity = 600 

# 绑定source、channel和sink之间的连接
ag1.sources.source1.channels = channel1
ag1.sinks.sink1.channel = channel1

4.启动flume
启动命令:(在flume的bin目录下启动)
./flume-ng agent -C …/conf/ -f …/dir-hdfs.conf -n ag1 -Dflume.root.logger=INFO.console
启动成功:
Flume配置文件(跟踪文件夹)_第2张图片
5.测试flume是否跟踪文件夹
在根目录下创建log文件夹并新建文件:
Flume配置文件(跟踪文件夹)_第3张图片
在这里插入图片描述

新建的文件成功显示.FINISHED并在HDFS上显示则跟踪成功
在这里插入图片描述
在这里插入图片描述

你可能感兴趣的:(Flume配置文件(跟踪文件夹))