修改kafka中某一主题的数据存留时间

我们都知道,kafka中默认消息的保留时间是7天,若想更改,需在配置文件
server.properties里更改选项:
log.retention.hours=168

但是有的时候我们需要对某一个主题的消息存留的时间进行变更,而不影响其他主题。

可以使用命令:
kafka-configs.sh –zookeeper localhost:2181 –entity-type topics –entity-name topicName –alter –add-config log.retention.hours=120
使得主题的留存时间保存为5天

如果报错的话,可以将时间单位更改成毫秒:
kafka-configs.sh –zookeeper localhost:2181 –entity-type topics –entity-name test –alter –add-config retention.ms=43200000

猜你喜欢

转载自blog.csdn.net/weixin_43255026/article/details/85333889