Flume:本地文件到Kafka

Flume下载地址

官网的配置 : https://flume.apache.org/FlumeUserGuide.html

apache-flume-1.6.0-bin.tar.gz
http://pan.baidu.com/s/1o81nR8e s832

apache-flume-1.5.2-bin.tar.gz
http://pan.baidu.com/s/1bp6tXVL 4n4z

官网
https://flume.apache.org/download.html

配置文件
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

建立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

这里写图片描述

启动Flume的配置文件

flume-ng agent -n agent1 -c conf -f ./flume-dirKakfa.properties
-Dflume.root.logger=DEBUG,console >./flume1.log 2>&1 &

查看监控程序
Flume:本地文件到Kafka_第1张图片

建立数据测试
Flume:本地文件到Kafka_第2张图片
Flume:本地文件到Kafka_第3张图片

启动Kafka消费者,分别在hadoop11和hadoop12
Flume:本地文件到Kafka_第4张图片
Flume:本地文件到Kafka_第5张图片

备注
日志监控路径,只要日志放入则被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

Flume:本地文件到Kafka_第6张图片

北京小辉微信公众号

Flume:本地文件到Kafka_第7张图片

大数据资料分享请关注

你可能感兴趣的:(【大数据】Flume1.9.0)