bin/kafka-topics.sh --zookeeper node01:2181 --create --topic t_cdr --partitions 30 --replication-factor 2
注: partitions指定topic分区数,replication-factor指定topic每一个分区的副本数html
bin/kafka-topics.sh --zookeeper node01:2181 --list
查看指定topic信息node
bin/kafka-topics.sh --zookeeper node01:2181 --describe --topic t_cdr
控制台向topic生产数据shell
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某分区偏移量最大(小)值ui
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --topic hive-mdatabase-hostsltable --time -1 --broker-list node86:9092 --partitions 0
注: time为-1时表示最大值,time为-2时表示最小值this
为topic t_cdr 增长10个分区spa
bin/kafka-topics.sh --zookeeper node01:2181 --alter --topic t_cdr --partitions 10
删除topic,慎用,只会删除zookeeper中的元数据,消息文件须手动删除线程
bin/kafka-run-class.sh kafka.admin.DeleteTopicCommand --zookeeper node01:2181 --topic t_cdr
查看topic消费进度code
这个会显示出consumer group的offset状况, 必须参数为--group, 不指定--topic,默认为全部topicserver
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
分类: Kafka系列