flume 實(shí)戰(zhàn)

這里有非常全的例子
http://www.aboutyun.com/thread-8917-1-1.html
這里是官方文檔
http://flume.apache.org/
現(xiàn)在要實(shí)現(xiàn)一個(gè)flume發(fā)送數(shù)據(jù)到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.生產(chǎn)者

telnet 127.0.0.1 44444

4.消費(fèi)

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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容