set config retention.ms=3600000 仍然数据没有从 Kafka 中删除
set config retention.ms=3600000 still data not delete from 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小时后不删除数据?
检查 log.retention.check.interval.ms
的值。
此值会影响日志清理器。它将检查是否有任何日志符合此间隔的删除条件。
根据 describe 命令结果,主题保留策略设置为 compact
,这将启用日志压缩而不是删除,并将保留每个键的最新数据。要删除所有超过保留期的数据,您需要将保留策略设置为 delete
。
./bin/kafka-topics.sh --zookeeper zookeeper:2181 --alter --topic topic_1 --config cleanup.policy=delete
如文档所示,retention.ms 控制 kafka 在丢弃旧日志段以释放日志之前保留日志的最长时间 space 如果我们使用 "delete" 保留政策。
看起来你的 cleanup.policy
设置为紧凑而不是 delete
bin/kafka-configs.sh --zookeeper 2181 --entity-type topics
--entity-name topic_1 --alter --add-config cleanup.policy=delete
PS:从 kafka-topics.sh 脚本 (kafka.admin.TopicCommand) 更改主题配置已被弃用。今后,请使用 kafka-configs.sh 脚本 (kafka.admin.ConfigCommand) 来实现此功能。
我已经通过以下命令设置了 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小时后不删除数据?
检查 log.retention.check.interval.ms
的值。
此值会影响日志清理器。它将检查是否有任何日志符合此间隔的删除条件。
根据 describe 命令结果,主题保留策略设置为 compact
,这将启用日志压缩而不是删除,并将保留每个键的最新数据。要删除所有超过保留期的数据,您需要将保留策略设置为 delete
。
./bin/kafka-topics.sh --zookeeper zookeeper:2181 --alter --topic topic_1 --config cleanup.policy=delete
如文档所示,retention.ms 控制 kafka 在丢弃旧日志段以释放日志之前保留日志的最长时间 space 如果我们使用 "delete" 保留政策。
看起来你的 cleanup.policy
设置为紧凑而不是 delete
bin/kafka-configs.sh --zookeeper 2181 --entity-type topics
--entity-name topic_1 --alter --add-config cleanup.policy=delete
PS:从 kafka-topics.sh 脚本 (kafka.admin.TopicCommand) 更改主题配置已被弃用。今后,请使用 kafka-configs.sh 脚本 (kafka.admin.ConfigCommand) 来实现此功能。