删除主题级别配置

sil*_*sil 4 apache-kafka

为了删除主题中的所有数据,我将其retention.ms配置设置为1000。

./bin/kafka-topics.sh --zookeeper $KAFKAZKHOSTS --alter --topic <topic> --config retention.ms=1000
Run Code Online (Sandbox Code Playgroud)

这很好用。经过很短的等待后,所有数据都被删除。

在更改配置之前,未在主题上设置retention.ms,因此服务器默认属性log.retention.hours=168是之前的保留策略。(log.retention.mines 和 log.retention.ms 尚未在服务器属性中设置)。

现在我想从本主题中完全删除retention.ms 配置并返回使用服务器级别配置。

命令如

./bin/kafka-topics.sh --zookeeper $KAFKAZKHOSTS --alter --topic <topic> --config retention.ms=
Run Code Online (Sandbox Code Playgroud)

或者

./bin/kafka-topics.sh --zookeeper $KAFKAZKHOSTS --alter --topic <topic> --config retention.ms=null
Run Code Online (Sandbox Code Playgroud)

抛出一个错误。

我知道 kafka-topics.sh 的删除选项实际上会删除整个主题,所以我不会尝试使用它。

问题:如何完全删除主题级别配置,以便主题恢复为使用服务器默认设置?

Mic*_*son 11

要删除主题配置覆盖,您可以使用该kafka-config工具。例如:

./bin/kafka-configs.sh --zookeeper <zookeeper> --alter \
  --entity-type topics --entity-name <topic> --delete-config retention.ms
Run Code Online (Sandbox Code Playgroud)