1、首先在3台服务器上启动zookeeper
2、启动3台服务器上的kafka-server
3、编写flume数据发送给kafka的配置文件
再flume的conf下编写一个fktest.conf
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
# 和kafka之间通信的协议
a1.sources.r1.type = avro
# 源数据绑定再哪台机器上
a1.sources.r1.bind = hdp-1
# 通信端口
a1.sources.r1.port = 41414
# Describe the sink
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.topic = kafkatopic
a1.sinks.k1.brokerList = hdp-1:9092,hdp-2:9092,hdp-3: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 = 1000000
a1.channels.c1.transactionCapacity = 10000
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
在第一台服务器上启动flume
flume-ng agent -n a1 -c conf -f conf/fktest.conf -Dflume.root.logger&#