1、kafka默认数据过期时间是7天
在配置文件中可配置 config/server.properties
log.retention.hours=72 (配置该参数即可,默认是168)
log.cleanup.policy=delete
这种方式设置kafka各个节点后需要重启
2、查看topic消息过期时间
./kafka-configs.sh –bootstrap-server localhost:9092 –describe –entity-name test –entity-type topics
3、修改topic消息过期时间,单位ms
./kafka-configs.sh –bootstrap-server localhost:9092 –alter –entity-name test –entity-type topics –add-config retention.ms=360000