Modifying message topics
Once created, topics can be modified. For example, when a new node is added to the cluster or a different parallelism is needed. Sometimes, deleting the topic and starting over is not the correct solution.
Getting ready
For this recipe, Kafka must be installed, ZooKeeper should be running, and the broker should be running with some topics created on it.
How to do it...
- Run the following command from the Kafka installation directory:
$ bin/kafka-topics.sh --zookeeper localhost:2181/chroot --alter --topic test-topic --partitions 40 --config delete.retention.ms=10000 --delete-config retention.ms
This command changes the delete.retention.ms
to 10 seconds and deletes the configuration retention.ms
Note
Kafka does not support reducing the number of partitions for a topic.
There is the kafka-configs
shell; the syntax to add and remove is as follows:
- To add a config to a topic, run the following:
$ bin/kafka-configs.sh --zookeeper host:port/chroot --entity-type topics --entity-name...