kafka 常用命令
---查看生成和消费队列的消息数量
kafka-run-class.bat kafka.tools.ConsumerOffsetChecker --topic test --zookeeper localhost:2181 --group test1
格式:kafka-run-class.bat kafka.tools.ConsumerOffsetChecker --topic 标题 --zookeeper 服务地址:端口 --group 消费组名称
topic:创建时topic名称
partition:分区编号
offset:表示该parition已经消费了多少条message
logSize:表示该partition已经写了多少条message
Lag:表示有多少条message没有被消费。
Owner:表示消费者
Created:该partition创建时间
Last Seen:消费状态刷新最新时间。
--- 创建标题()
kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test1
格式:kafka-topics.bat --create --zookeeper 服务地址:端口 --replication-factor 备份数量 --partitions 分区数 --topic 标题
--查看标题列表
kafka-topics.sh --list --zookeeper localhost:2181
kafka-topics.bat --list --zookeeper 服务地址:端口
--删除标题
Kafka 删除topic的命令是:
kafka-topics.bat --delete --zookeeper 【zookeeper server】 --topic 【topic name】
如果kafaka启动时加载的配置文件中server.properties没有配置delete.topic.enable=true
,那么此时的删除并不是真正的删除,而是把topic标记为:marked for deletion
--生产消息
kafka-console-producer.bat --broker-list localhost:9092 --topic test
kafka-console-producer.bat --broker-list kafka服务ip:9092 --topic 标题
---启动消费者,查看信息
kafka-console-consumer.bat --zookeeper localhost:2181 --topic test --from-beginning
kafka-console-consumer.bat --zookeeper 服务地址:端口 --topic 标题 --from-beginning
猜你喜欢
转载自gjp014.iteye.com/blog/2369860
今日推荐
周排行