1. 创建topic
kafka-topics.sh --create --topic test --bootstrap-server localhost:9092 --replication-factor 2 --partitions 3
参数说明:
--create:创建主题的动作指令
--replication-factor:指定副本因子(副本数量),表示该topic需要在不同的broker中保存几份
--partitions:指定分区个数
--topic:指定所创建的主题名称
2. 查看topic
kafka-topics.sh --list --bootstrap-server localhost:9092
3. 查看topic属性
kafka-topics.sh --describe --topic test --bootstrap-server localhost:9092
4. 生产者
kafka-console-producer.sh --topic test --bootstrap-server localhost:9092
5. 消费者
kafka-console-consumer.sh --topic test --bootstrap-server localhost:9092
6. 删除topic
kafka-topic.sh --delete --topic test --bootstrap-server localhost:9092
7. 修改分区数
kafka-topic.sh --alter --topic test --partitions 5