Kafka topic record
1. Create topic
./kafka-topics.sh --create --zookeeper ip:port --replication-factor 1 --partitions 2 --topic my-topic
among --replication-factor
Number of configured replicas, --partitions
Configure the number of partitions
2. View topic details
./kafka-topics.sh --describe --zookeeper ip:port --topic my-topic
3. List all topics
./kafka-topics.sh --list --zookeeper ip:port
4. Delete topic
./kafka-topics.sh --delete --zookeeper ip:port --topic my-topic
5. Modify the duration of topic saving messages
./kafka-configs.sh --zookeeper ip:port --alter --entity-type topics --entity-name my-topic --add-config retention.ms=172800000
retention.ms=172800000
Configured for retention for 2 days
6. Increase the number of topic partitions
./kafka-topics.sh --alter --zookeeper ip:port --topic my-topic --partitions 3
The number of extended partitions can only be increased, not decreased. If you want to reduce the number of partitions, you can only delete the original topic and rebuild it.
This article is written by Chakhsu Lau Creation, adoption Knowledge Sharing Attribution 4.0 International License Agreement.
All articles on this website are original or translated by this website, except for the reprint/source. Please sign your name before reprinting.