node01改成localhost或者127.0.0.1
查看所有topic列表
bin/kafka-topics.sh --zookeeper node01:2181 --list
查看指定topic信息
bin/kafka-topics.sh --zookeeper node01:2181 --describe --topic t_cdr
控制台向topic生产数据
bin/kafka-console-producer.sh --broker-list node86:9092 --topic t_cdr
控制台消费topic的数据
bin/kafka-console-consumer.sh --zookeeper node01:2181 --topic t_cdr --from-beginning
查看topic某分区偏移量最大(小)值
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --topic hive-mdatabase-hostsltable --time -1 --broker-list node86:9092 --partitions 0
删除topic,慎用,只会删除zookeeper中的元数据,消息文件须手动删除
bin/kafka-run-class.sh kafka.admin.DeleteTopicCommand --zookeeper node01:2181 --topic t_cdr
查看topic消费进度
这个会显示出consumer group的offset情况, 必须参数为–group, 不指定–topic,默认为所有topic
Displays the: Consumer Group, Topic, Partitions, Offset, logSize, Lag, Owner for the specified set of Topics and Consumer Group
bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker
required argument: [group]
Option Description
–broker-info Print broker info
–group Consumer group.
–help Print this message.
–topic Comma-separated list of consumer
topics (all topics if absent).
–zkconnect ZooKeeper connect string. (default: localhost:2181)
Example,
bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --group pv
Group Topic Pid Offset logSize Lag Owner
pv page_visits 0 21 21 0 none
pv page_visits 1 19 19 0 none
pv page_visits 2 20 20 0 none
以上图中参数含义解释如下:
topic:创建时topic名称
pid:分区编号
offset:表示该parition已经消费了多少条message
logSize:表示该partition已经写了多少条message
Lag:表示有多少条message没有被消费。
Owner:表示消费者
写在最后
本文只是文字的搬运工,感谢“XIAO的博客” 这篇文章
https://www.cnblogs.com/xiaodf/p/6093261.html