查看topic列表
bin/kafka-topics.sh --bootstrap-server localhost:9093 --list
创建topic
bin/kafka-topics.sh --create --zookeeper sf01.tendcloud.com:2181 --replication-factor 2 --partitions 2 --topic fl0316
查看offset
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9093 --topic fl0316
查看分区详情
bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic fl0316
生产数据
bin/kafka-console-producer.sh --broker-list localhost:9093 --topic fl0316
消费数据
bin/kafka-console-consumer.sh --bootstrap-server localhost:9093 --consumer-property group.id=fl0315-c --topic fl0316
新增topic的partitions
bin/kafka-topics.sh --alter --zookeeper localhost:2181 --partitions 5 --topic fl0316
自动分区
bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --topics-to-move-json-file topic-to-move.json --broker-list “0,1,2,3” --generate
执行分区
bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file p.json --execute
确认分区信息
bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file p.json --verify
删除topic
bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic fl0316