Flume采集端口数据kafka消费
1.flume单独搭建
#cd /root/flume
#vi conf/necat.conf
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# sources
a1.sources.r1.type = netcat
a1.sources.r1.bind = master
a1.sources.r1.port = 44444
# sinks
a1.sinks.k1.type = logger
# channels
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# merge
a1.sources.r1.channels = c1
a1.sinks.k1.channels = c1
# 启动
cd /root/flume
nc -lk ip 44444(开端口)
/root/flume/bin/flume-ng agent -n a1 -c /root/flume/conf -f /root/flume/conf/netcat.conf -Dflume.root.logger=INFO,console
2.Flume采集端口数据kafka消费
# 采端口
cd /root/flume
vi conf/nc.conf
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# sources
a1.sources.r1.type =netcat
a1.sources.r1.bind = master
a1.sources.r1.port = 7777
# sinks
a1.sinks.k1.type=org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.kafka.topic=test
a1.sinks.k1.kafka.bootstrap.servers=master:9092
a1.sinks.k1.kafka.producer.acks=1
# channels
a1.channels.c1.type=memory
a1.channels.c1.capacity=1000
a1.channels.c1.transactionCapacity=100
# merge
a1.sources.r1.channels=c1
a1.sinks.k1.channel=c1
#先开kafka消费
cd /root/kafka
/root/kafka/bin/kafka-console-consumer --bootstrap-server master:9092 --topic test
#再开flume
cd /root/flume
/root/flume/bin/flume-ng agent -n a1 -c /root/flume/conf -f /root/flume/conf/nc.conf -Dflume.root.logger=INFO,console
#再开nc连接端口
nc master 7777
#nc master 7777
输入数据,kafka消费可以看到
文章来源地址https://www.toymoban.com/news/detail-736824.html
文章来源:https://www.toymoban.com/news/detail-736824.html
到了这里,关于Flume采集端口数据kafka消费的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!