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

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

问题描述

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

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

我该怎么做?

推荐答案

你之前问过这个问题,我已经在这里回复了:使用Java更新kafka中特定主题的TTL

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天全站免登陆