1. View topic information in kafka queue
1.1. View all topics
./kafka-topics.sh --zookeeper 10.128.106.52:2181 --list
1.2. View details of the specified topic in kafka
./kafka-topics.sh --zookeeper 10.128.106.52:2181 --topic ai_jl_analytic --describe
2. View the consumer group list
2.1 View all groups
./kafka-consumer-groups.sh --bootstrap-server 10.128.106.52:9092 --list
2.2 View the specified group
./kafka-consumer-groups.sh --bootstrap-server 10.128.106.52:9092 --group ai-trace --describe
3. Create, modify, and delete topics
3.1 Create topic
./kafka-topics.sh --create --zookeeper 10.128.106.52:2181 --topic test --partitions 8 --replication-factor 1
#创建topic名为test,分区数为8,副本数为1
3.2 Modify the number of topic partitions
./kafka-topics.sh --zookeeper 10.128.106.52:2181 -alter --partitions 12 --topic test
3.3 Delete topic
./kafka-topics.sh --zookeeper 10.128.106.52:2181 --delete --topic test
When executing the topic deletion command, a prompt appears.
Topic test is marked for deletion.
Note: This will have no impact if delete.topic.enable is not set to true.
This command does not actually perform the deletion action. It just marks the topic to be deleted on zookeeper. It also reminds the user to turn on the delete.topic.enable switch in advance, otherwise the deletion action will not be executed. of.
Solution:
a) Set the delete.topic.enable parameter to true in server.properties
b) Do as follows :
1. Log in to the zookee client: ./bin/zookeeper-client
2. Find the directory where the topic is located: ls /brokers/topics
3. Execute Delete command: rmr /brokers/topics/test
4. Simulate producers/consumers
4.1 Producers produce messages:
./kafka-console-producer.sh --broker-list 10.128.106.52:9092 --topic test
4.2 Consumer consumption news:
./kafka-console-consumer.sh --bootstrap 10.128.106.52:9092 --topic server