kafka flume 对接

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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值