Kafka topic configuration usage record
in Note with 0 comment
Kafka topic configuration usage record
in Note with 0 comment

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.

Responses