flume整合kafka之kafka接收flume数据



1.创建配置文件 基本配置如下:


#source
a1.sources = sysSrc
a1.sources.sysSrc.type=avro
a1.sources.sysSrc.bind=0.0.0.0
a1.sources.sysSrc.port=33333
a1.sources.sysSrc.channels=fileChannel


#channel
a1.channels = fileChannel
a1.channels.fileChannel.type =memory
a1.channels.fileChannel.capacity=10000


#sink
a1.sinks = kafkaSink
a1.sinks.kafkaSink.channel=fileChannel
a1.sinks.kafkaSink.type=org.apache.flume.sink.kafka.KafkaSink
a1.sinks.kafkaSink.brokerList=h4:9092
a1.sinks.kafkaSink.custom.partition.key=kafkaPartition
a1.sinks.kafkaSink.topic=T20161031
a1.sinks.kafkaSink.serializer.class=kafka.serializer.StringEncoder




2. 保证zookeeper正常启动同时kafka也正常启动的情况下启动flume
bin/flume-ng agent --conf conf --conf-file conf/sink2Kafka.conf --name a1 -Dflume.root.logger=INFO,console


3. 启动kafka消费者现场 
bin/kafka-console-consumer.sh --zookeeper h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181 --topic T20161031 --from-beginning


4. 利用flume带的avro客户端向flume发送消息
bin/flume-ng avro-client --conf conf --host 0.0.0.0 --port 33333 --filename ../mydata/log2.txt


结果:可以看到kafka主题T20161031正确收到来自flume的avro客户端发送的消息


补充:其他flume的source如spooldir  netcat等按照固定规则测试即可
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值