栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

flume对接kafka测试

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

flume对接kafka测试

Flume对接Kafka测试 配置文件
# example.conf: A single-node Flume configuration

# 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
a1.sinks.k1.kafka.topic = mytopic
a1.sinks.k1.kafka.bootstrap.servers = server1:9092,server2:9092,server3:9092
a1.sinks.k1.kafka.flumeBatchSize = 20

# 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
bin/flume-ng agent --conf conf --conf-file conf/example.conf --name a1 -Dflume.root.logger=INFO,console
telnet localhost 44444

三个节点都开启kafka服务

bin/kafka-server-start.sh config/server.properties &

启动之后输入exit,再重新登录

exit

创建topic

bin/kafka-topics.sh --zookeeper server1:2181,server2:21821,server3:2181 
--create --replication-factor 3 --partitions 1 --topic mytopic

启动消费者

bin/kafka-console-consumer.sh 
--zookeeper server1:2181,server2:2181,server3:2181 --from-beginning --topic mytopic

随便在telnet的窗口输入点什么,观察消费者窗口

补充命令

查看所有topic

bin/kafka-topics.sh --zookeeper server3:2181 --list

删除topic

bin/kafka-topics.sh --zookeeper server1:2181 
--delete --topic first

启动生产者

bin/kafka-console-producer.sh 
--broker-list server1:9092 --topic first

查看某个topic详情

bin/kafka-topics.sh --zookeeper hadoop102:2181 
--describe --topic first

停止服务

bin/kafka-server-stop.sh stop
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/282583.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号