【注意】flume+kafka版本搭配
flume-1.7.0 + kafka_2.11-2.3
jdk安装#:yum install -y java-1.8.0-openjdk-devel.x86_64
flume安装#:
参考:[https://www.cnblogs.com/man-li/p/4362264.html]
http://ftp.jaist.ac.jp/pub/apache/flume/1.7.0/
apache-flume-1.7.0-bin.tar.gz
apache-flume-1.7.0-src.tar.gz
启动命令:bin/flume-ng agent --conf conf/ --name a1 --conf-file job/flume-kafka.conf
flume配置样例#
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /opt/logdir/testfile
# Describe the sink
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.topic = test
a1.sinks.k1.brokerList = 192.168.221.135:9092
a1.sinks.k1.requiredAcks = 1
a1.sinks.k1.batchSize = 20
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
kafka 安装#:
linux下安装kafka 下载Binary模式源码,不然有报错.
# start kafka:
nohup /root/kafka_2.11-2.3.0/bin/kafka-server-start.sh config/server.properties >>/opt/kafka.log 1>/dev/null 2>/dev/null &
nohup /root/kafka_2.11-2.3.0/bin/zookeeper-server-start.sh config/zookeeper.properties >> /opt/zookpeer.log 1>/dev/null 2>/dev/null &
# producer:
bin/kafka-console-producer.sh --broker-list 192.168.221.135:9092 --topicstes
# consumer:
bin/kafka-console-consumer.sh --bootstrap-server 192.168.221.135:9092 --topic test --from-beginning
flume读取文件写kafka成功#

网友评论