删除主题级别配置 [英] Delete topic level config
问题描述
为了删除主题中的所有数据,我将它的retention.ms 配置设置为 1000.
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.
在更改配置之前,retention.ms 未在主题上设置,因此服务器默认属性 log.retention.hours=168 是以前的保留策略.(未在服务器属性中设置 log.retention.minutes 和 log.retention.ms).
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).
现在我想从本主题中完全删除retention.ms 配置并返回使用服务器级别配置.
Now I would like to remove the retention.ms config from this topic completely and go back to using the server level config.
类似命令
./bin/kafka-topics.sh --zookeeper $KAFKAZKHOSTS --alter --topic <topic> --config retention.ms=
或
./bin/kafka-topics.sh --zookeeper $KAFKAZKHOSTS --alter --topic <topic> --config retention.ms=null
抛出一个错误.
我知道 kafka-topics.sh 的删除选项实际上会删除整个主题,所以我不会尝试使用它.
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?
推荐答案
要删除主题配置覆盖,您可以使用 kafka-config
工具.例如:
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
这篇关于删除主题级别配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!