Kafka series: View Topic list, message consumption, simulated producers and consumers

1. View topic information in kafka queue

1.1. View all topics

./kafka-topics.sh --zookeeper 10.128.106.52:2181 --list

Insert image description here

1.2. View details of the specified topic in kafka

./kafka-topics.sh --zookeeper 10.128.106.52:2181 --topic ai_jl_analytic --describe

Insert image description here

2. View the consumer group list

2.1 View all groups

./kafka-consumer-groups.sh --bootstrap-server 10.128.106.52:9092 --list

Insert image description here

2.2 View the specified group

./kafka-consumer-groups.sh --bootstrap-server 10.128.106.52:9092 --group ai-trace --describe

Insert image description hereInsert image description here

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

Insert image description hereInsert image description here

3.2 Modify the number of topic partitions

./kafka-topics.sh --zookeeper 10.128.106.52:2181 -alter --partitions 12 --topic test

Insert image description here

3.3 Delete topic

./kafka-topics.sh --zookeeper 10.128.106.52:2181 --delete --topic test

Insert image description here

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
Insert image description here

4. Simulate producers/consumers

4.1 Producers produce messages:

./kafka-console-producer.sh --broker-list 10.128.106.52:9092 --topic test

Insert image description here

4.2 Consumer consumption news:

./kafka-console-consumer.sh --bootstrap 10.128.106.52:9092 --topic server

Insert image description here

Guess you like

Origin blog.csdn.net/YJ000312/article/details/129832279