1,前置条件:(这些清参考之前文章)
1,安装好zk集群,安装好kafka集群 (准备三台weekend01,weekend02,weekend03)2,安装好Flume
2、创建flume配置文件
cd /usr/app/apache-flume-1.6.0-bin/conf
mkdir myconf
vi exec.conf
a1.sources = r1
a1.channels = c1
a1.sinks = k1
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /export/data/flume_sources/click_log/1.log
a1.sources.r1.channels = c1
a1.channels.c1.type = memory
a1.channels.c1.capacity = 10000
a1.channels.c1.transactionCapacity = 100
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.topic = orderMq
a1.sinks.k1.brokerList = weekend01:9092
a1.sinks.k1.requiredAcks = 1
a1.sinks.k1.batchSize = 20
a1.sinks.k1.channel = c1
5.1 启动zk集群 (bin目录下 ./zkServer.sh start)
5.2 启动kafka集群 (三个虚拟机上都要启动)
kafka-server-start.sh /usr/app/kafka_2.10-0.8.1.1/config/server.properties
5.4 开启一个consumer 监视topic产生的数据
5.5 执行脚本产生生产数据
sh click_log_out.sh
然后你再启动consumer的虚拟机下可以看到输出了数据如图:
到这里kafka整合flume介绍完毕了。
大家也可以加上 strom 作为消费者与kafka和flume整合在一起(strom整合kafka之前文章也有详解)