sil
sil

Reputation: 450

Delete topic level config

In order to delete all of the data in a topic I set the retention.ms config of it to 1000.

./bin/kafka-topics.sh --zookeeper $KAFKAZKHOSTS --alter --topic <topic> --config retention.ms=1000

This worked fine. All the data was deleted after a very short wait.

Before altering the config, the retention.ms was not set on the topic and so the server default property log.retention.hours=168 was the previous retention policy. (log.retention.minutes and log.retention.ms had not been set in the server properties).

Now I would like to remove the retention.ms config from this topic completely and go back to using the server level config.

Commands like

./bin/kafka-topics.sh --zookeeper $KAFKAZKHOSTS --alter --topic <topic> --config retention.ms=

or

./bin/kafka-topics.sh --zookeeper $KAFKAZKHOSTS --alter --topic <topic> --config retention.ms=null

throw an error.

I know that the delete option for kafka-topics.sh actually deletes the entire topic, so I'm not going to try play around with that.

Question: How do I completely remove a topic level config so that the topic reverts to using the server default?

Upvotes: 4

Views: 5461

Answers (2)

ASK
ASK

Reputation: 1274

Another traditional solution which I used is manually deleting the particular folder for particular topic.

  1. First stop the kafka server
  2. Go to /var/lib/kafka/data (where your kafka data ios being stored specifies by you at the time of installation)
  3. rm -rf /var/lib/kafka/data/yourTopicName-0

Upvotes: -3

Mickael Maison
Mickael Maison

Reputation: 26885

To remove a topic configuration override, you can use the kafka-config tool. For example:

./bin/kafka-configs.sh --zookeeper <zookeeper> --alter \
  --entity-type topics --entity-name <topic> --delete-config retention.ms

Upvotes: 11

Related Questions