1、kafka默认数据过期时间是7天
在配置文件中可配置 config/server.properties
log.retention.hours=72 (配置该参数即可,默认是168)
log.cleanup.policy=delete
这种方式设置kafka各个节点后需要重启
bin/kafka-server-stop.sh
bin/kafka-server-start.sh -daemon config/server.properties &
创建主题
./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testtopic
2、修改topic消息过期时间
./kafka-configs.sh --bootstrap-server localhost:9092 --alter --entity-name testtopic --entity-type topics --add-config retention.ms=20000
3、查看topic消息过期时间
./kafka-configs.sh --bootstrap-server localhost:9092 --describe --entity-name testtopic --entity-type topics
对kafka主题的操作可参考
kafka命令查看主题topic创建主题topic查看主题topic详情,删除topic消费者生产者
最后修改于 2021-10-22 14:45:58
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

