apache-kafka - 设置配置保留.ms=3600000 仍然没有从 Kafka 中删除数据
问题描述
我已通过以下命令设置了retention.ms=3600000,但1小时后磁盘上仍有大量数据。由于大量数据传入 Kafka,我的磁盘已满。
./bin/kafka-topics.sh --zookeeper zookeeper:2181 --alter --topic topic_1 --config retention.ms=3600000
描述命令
./bin/kafka-topics.sh --zookeeper zookeeper:2181 --describe --topics-with-overrides
Topic:__consumer_offsets PartitionCount:50 ReplicationFactor:3 Configs:segment.bytes=104857600,cleanup.policy=compact,compression.type=producer
Topic:topic_1 PartitionCount:3 ReplicationFactor:3 Configs:retention.ms=3600000
Topic:topic_2 PartitionCount:3 ReplicationFactor:3 Configs:retention.ms=3600000
Topic:topic_3 PartitionCount:3 ReplicationFactor:3 Configs:retention.ms=3600000,retention.bytes=104857600
谁能给出建议,为什么kafka在1小时后不删除数据。?
解决方案
从 describe 命令结果来看,主题保留策略设置为compact
启用日志压缩而不是删除,并将保留每个键的最新数据。要删除所有超过保留期的数据,您需要将保留策略设置为delete
。
./bin/kafka-topics.sh --zookeeper zookeeper:2181 --alter --topic topic_1 --config cleanup.policy=delete
推荐阅读
- angular - 由于 MSAL Angular 中的超时,令牌更新操作失败
- express - vue使用axios上传文件到azure blob,但是后端服务器收不到body值
- mysql - 为什么 dockerfile 不能用“ CMD /etc/init.d/mysql start ”启动数据库?
- javascript - JsPDF 和 chart.js:提高图表分辨率
- reactjs - react-router-dom v6 useNavigate 将值传递给另一个组件
- airflow - Prometheus:如何根据任何 Airflow Dag 而不是特定 Airflow Dag 的结果创建警报
- c++ - const auto 和 const type 有什么区别*
- css - 如何用 CSS 制作动画
- ios - Flutter iOS Rich Push Notification Image 不显示
- angular - Angular Observable 的数据绑定