flume 实战

这里有非常全的例子
http://www.aboutyun.com/thread-8917-1-1.html
这里是官方文档
http://flume.apache.org/
现在要实现一个flume发送数据到kafka的例子

Paste_Image.png

1.启动zookeeper,kafka

2.配置文件

注意我用的是1.6 一定要和官方文档一致才行
配置文件

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444

# Describe the sink
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
#send to kafka
a1.sinks.k1.brokerList  = master:9092,slave1:9092,slave2:9092
a1.sinks.k1.serializer.class = kafka.serializer.StringEncoder
a1.sinks.k1.requiredAcks = 1
a1.sinks.k1.topic = test

# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

2.启动

./bin/flume-ng agent --conf ./conf -f ./conf/flume-conf.properties -Dflume.root.logger=INFO,console -n a1 &

3.生产者

telnet 127.0.0.1 44444

4.消费

./bin/kafka-console-consumer.sh --zookeeper master:2181,slave1:2181,slave2:2181 --topic test --from-beginning

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容