You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何无限期存储Kafka事件?Broker配置参数确认

Kafka 2.2.0 (Confluent 5.2.1) 无限期存储事件的配置验证

Great question! Let me break this down based on hands-on experience with Kafka 2.2.0 (bundled with Confluent 5.2.1):

1. Are log.retention.ms=-1 and log.retention.bytes=-1 valid for infinite retention?

Absolutely. Even if the official docs don’t explicitly label this as "infinite retention", setting these parameters to -1 is the de facto standard approach to disable time-based and size-based log retention in this version.

  • log.retention.ms=-1 turns off automatic deletion of log segments based on their age
  • log.retention.bytes=-1 turns off automatic deletion triggered by the total size of log segments for a topic

This combination ensures Kafka won’t remove your events due to hitting a time or size threshold.

2. Are these two parameters enough?

Almost, but there’s one more critical setting to verify to guarantee full infinite retention:

  • log.cleanup.policy: The default value is delete, which pairs perfectly with your existing configs. However, if this is set to compact or delete,compact, Kafka will still perform log compaction—removing older records with duplicate keys, even when retention time/size limits are disabled.

If your goal is to retain every single event (including duplicates), make sure log.cleanup.policy stays set to delete.

Quick verification tip

To confirm your settings are working as expected:

  • Check the broker logs for any messages about log segment deletion (you shouldn’t see any for topics using these configs)
  • Use the kafka-log-dump.sh tool to inspect log segments for a test topic—you’ll see all your events remain intact over time

内容的提问来源于stack exchange,提问作者J S

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:57:15