如何在Kafka中为特定主题更改TTL [英] How to alter the TTL for a particular topic in Kafka

查看:35
本文介绍了如何在Kafka中为特定主题更改TTL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将特定Kafka主题的TTL更新为10天.

I would like to update the TTL of a specific Kafka topic to 10 days.

我该怎么做?

推荐答案

您之前曾问过这个问题,我已经在这里回答过:

You previously asked about that and I already replied here : Update TTL for a particular topic in kafka using Java

除非您要使用Kafka工具进行操作,否则?(而不是Java)在这种情况下,有kafka-topics.sh命令行工具,可让您使用--alter选项执行此操作.

Unless you are asking to do that using Kafka tools? (And not in Java) In this case there is the kafka-topics.sh command line tool, allowing you to do that using the --alter option.

bin/kafka-topics.sh --alter --zookeeper localhost:2181 --topic test --config retention.ms=10000

由于在下一版本中可以删除使用kafka-topics脚本进行的更改,因此您应该使用kafka-configs脚本:

Because altering using kafka-topics script could be removed in next release, you should use the kafka-configs script:

bin/kafka-configs.sh --zookeeper localhost:2181 --alter --entity-type topics --entity-name test --add-config retention.ms=5000

这篇关于如何在Kafka中为特定主题更改TTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆