kafka设置某个topic的数据过期时间


kafka 单独设置某个topic的数据过期时间

kafka 默认存放7天的临时数据,如果遇到磁盘空间小,存放数据量大,可以设置缩短这个时间。

全局设置

修改 server.properties

log.retention.hours=72
log.cleanup.policy=delete

单独对某一个topic设置过期时间

但如果只有某一个topic数据量过大。
想单独对这个topic的过期时间设置短点:

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

retention.ms=86400000 为一天,单位是毫秒。

查看设置:

$ ./kafka-configs.sh --zookeeper localhost:2181 --describe --entity-name mytopic --entity-type topics
Configs for topics:wordcounttopic are retention.ms=86400000

立即删除某个topic下的数据

./kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config cleanup.policy=delete


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM