配置文件
cd /usr/app/flume1.6/conf
vi flume-dirKakfa.properties
#agent1 name
agent1.sources=source1
agent1.sinks=sink1
agent1.channels=channel1
#Spooling Directory
#set source1
agent1.sources.source1.type=spooldir
agent1.sources.source1.spoolDir=/usr/app/flumelog/dir/logdfs
agent1.sources.source1.channels=channel1
agent1.sources.source1.fileHeader = false
agent1.sources.source1.interceptors = i1
agent1.sources.source1.interceptors.i1.type = timestamp
#set sink1
agent1.sinks.sink1.type = org.apache.flume.sink.kafka.KafkaSink
agent1.sinks.sink1.topic = Flumelog
agent1.sinks.sink1.brokerList = hadoop11:9092,hadoop12:9092
agent1.sinks.sink1.requiredAcks = 1
agent1.sinks.sink1.batchSize = 100
agent1.sinks.sink1.channel = channel1
#set channel1
agent1.channels.channel1.type=file
agent1.channels.channel1.checkpointDir=/usr/app/flumelog/dir/logdfstmp/point
agent1.channels.channel1.dataDirs=/usr/app/flumelog/dir/logdfstmp
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
建立Linux目录
[root@hadoop11 app]# mkdir /usr/app/flumelog/dir
[root@hadoop11 app]# mkdir /usr/app/flumelog/dir/logdfs
[root@hadoop11 app]# mkdir /usr/app/flumelog/dir/logdfstmp
[root@hadoop11 app]# mkdir /usr/app/flumelog/dir/logdfstmp/point
建立kakfa的Topicname
bin/kafka-topics.sh --create --topic Flumelog --replication-factor 1 --partitions 2 --zookeeper hadoop11:2181
- 1
- 1
启动Flume的配置文件
flume-ng agent -n agent1 -c conf -f ./flume-dirKakfa.properties -Dflume.root.logger=DEBUG,console >./flume1.log 2>&1 &
- 1
- 2
- 1
- 2
查看监控程序
建立数据测试
启动Kafka消费者,分别在hadoop11和hadoop12
备注
日志监控路径,只要日志放入则被Flume监控
[root@hadoop11 app]# mkdir /usr/app/flumelog/dir/logdfs
日志读取完毕存储路径,日志在这里则一直存储在Channel中(最多只有两个log-number日志,且默认达到1.6G之后删除前面一个log,建立新的log)
[root@hadoop11 app]# mkdir /usr/app/flumelog/dir/logdfstmp
日志监控路径中文件的路径存放点
[root@hadoop11 app]# mkdir /usr/app/flumelog/dir/logdfstmp/point