kafka flume 对接
cd /home/aculearn/disk/apache-flume-1.8.0-bin/conf
配置flume sink
vim ka1.conf
a1.sources=s1
a1.channels=c1
a1.sinks=k1
a1.sources.s1.type=spooldir (源的模式为目录模式)
#a1.sources.s1.command=tail -F /tmp/logs/kafka.log
a1.sources.s1.spoolDir=/tmp/logs (自动收集logs目录下的文件并作为数据源)
a1.sources.s1.channels=c1
a1.channels.c1.type=memory
a1.channels.c1.capacity=10000
a1.channels.c1.transactionCapacity=100
#设置Kafka接收器
a1.sinks.k1.type=org.apache.flume.sink.kafka.KafkaSink (流的终点为sink到kafka)
#设置Kafka的broker地址和端口号
a1.sinks.k1.brokerList:9092=192.168.x.xxx
#设置Kafka的Topic
a1.sinks.k1.topic=kafkatest
#设置序列化方式
a1.sinks.k1.serializer.class=kafka.serializer.StringEncoder
a1.sinks.k1.channel=c1
bin/flume-ng agent --conf conf --conf-file conf/$1 --name a1 -Dflume.root.logger=INFO,console flume启动脚本
启动zookeeper
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties &
启动kafka
bin/kafka-server-start.sh -daemon config/server.properties &
创建topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic kafkatest
创建消费者
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic kafkatest --from-beginning
总结flume 成为了kafka 的消费者 我们只需要创建一个生产者就能消费数据了(机器192.168.x.xxx上有整套对接demo)