bin/kafka-topics.sh --zookeeper node01:2181 --create --topic t_cdr --partitions 30 --replication-factor 2
注: partitions指定topic分區數,replication-factor指定topic每一個分區的副本數javascript
bin/kafka-topics.sh --zookeeper node01:2181 --list
bin/kafka-topics.sh --zookeeper node01:2181 --describe --topic t_cdr
bin/kafka-console-producer.sh --broker-list node86:9092 --topic t_cdr
bin/kafka-console-consumer.sh --zookeeper node01:2181 --topic t_cdr --from-beginning
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --topic hive-mdatabase-hostsltable --time -1 --broker-list node86:9092 --partitions 0
注: time爲-1時表示最大值,time爲-2時表示最小值java
爲topic t_cdr 增長10個分區node
bin/kafka-topics.sh --zookeeper node01:2181 --alter --topic t_cdr --partitions 10
bin/kafka-run-class.sh kafka.admin.DeleteTopicCommand --zookeeper node01:2181 --topic t_cdr
這個會顯示出consumer group的offset狀況, 必須參數爲--group, 不指定--topic,默認爲全部topicpython
Displays the: Consumer Group, Topic, Partitions, Offset, logSize, Lag, Owner for the specified set of Topics and Consumer Groupshell
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