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系列