创建topic:
./kafka-topics.sh --create --zookeeper localhost:2182/kafka --replication-factor 3 --partitions 1 --topic test
删除topic:
./kafka-topics.sh --zookeeper localhost:2182 --topic test --delete
查看topic列表:
./kafka-topics.sh --zookeeper localhost:2182/kafka --list
查看topic详情:
./kafka-topics.sh --describe --zookeeper localhost:2182/kafka --topic test
增加topic的partition
./kafka-topics.sh --zookeeper localhost:2182 --topic test --partitions 4 --alter
生产消息:
./kafka-console-producer.sh --broker-list localhost:9092 --topic test
消费消息:
./kafka-console-consumer.sh --zookeeper localhost:2182/kafka --topic test --from-beginning
(从后面开始: --offset latest(earliest))
(指定分区: --partition 1; 指定个数 --max-messages 1)
查看topic指定partition的offset
./kafka-run-class.sh kafka.tools.GetOffsetShell --topic test --time -2 --broker-list localhost:9092 --partitions 0
修改topic isr:
./kafka-topics.sh --zookeeper localhost:2182/kafka --topic test --config min.insync.replicas=3 --alter
查看某个consumer group 消费情况
./kafka-consumer-groups.sh --describe --bootstrap-server localhost:8021 --group test
在高版本的kafka中,–zookeeper zk地址 替换为了 --bootstrap-server broker地址