本文共 653 字,大约阅读时间需要 2 分钟。
kafka 默认存放7天的临时数据,如果遇到磁盘空间小,存放数据量大,可以设置缩短这个时间。
修改 server.properties
log.retention.hours=72log.cleanup.policy=delete
但如果只有某一个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 topicsConfigs for topics:wordcounttopic are retention.ms=86400000
./kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config cleanup.policy=delete
转载地址:http://zxxzb.baihongyu.com/