配置文件信息
flume_kafka.conf
a1.sources = r1
a1.sinks = k1
a1.channels = c1
a1.sources.r1.type=exec
# 实时检查该文件是否发生变化,将变化的文件发送到sink
a1.sources.r1.command=tail -F /root/data/hbreal/hbreal_2019071422_2019071423.txt
#a1.sinks.k1.type=logger
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.kafka.topic = hbreal
a1.sinks.k1.brokerList = s2:9092
a1.sinks.k1.kafka.flumeBatchSize = 20
a1.sinks.k1.kafka.producer.acks = 1
a1.channels.c1.type=memory
a1.sources.r1.channels=c1
a1.sinks.k1.channel=c1
启动kafka
kafka-server-start.sh -daemon /soft/kafka/config/server.properties
创建主题
kafka-topics.sh --create --zookeeper s3:2181 --replication-factor 1 --partitions 3 --topic hbreal
生产者
kafka-console-producer.sh --broker-list s2:9092 --topic hbreal
消费者
kafka-console-consumer.sh --bootstrap-server s2:9092 --topic hbreal
启动flume收集程序
flume-ng agent -f ./flume_tail.conf -n a1 -Dflume.root.logger=INFO,console