I need to configure Kafka never to delete logs. Looking at their documentation, I see two kinds of parameters that control this:
The "log cleaner", described at http://kafka.apache.org/documentation.html#compaction. It seems that setting log.cleaner.enable = false
prevents the cleaner from deleting or compacting logs.
The "log retention" mechanism, described at http://kafka.apache.org/documentation.html#configuration under log.retention.<time scales>
. It seems that setting log.retention.ms = -1
signals infinite retention.
My question is:
What is the relationship between these two mechanisms, are these the only two, and are the above settings necessary and sufficient to prevent logs from ever being deleted?
log.retention.hoursThe most common configuration for how long Kafka will retain messages is by time. The default is specified in the configuration file using the log. retention. hours parameter, and it is set to 168 hours, the equivalent of one week.
Method 1) If your Kafka allow plaintext connections (via port 9092) you can do it getting into a kafka pod. Method 2) You can do it getting into zookeeper pod. You can still use deprecated script kafka-topics.sh to change retention period for a topic.
The Kafka cluster retains all published messages—whether or not they have been consumed—for a configurable period of time. For example if the log retention is set to two days, then for the two days after a message is published it is available for consumption, after which it will be discarded to free up space.
Not sure which version you are using. For me, I use this:
log.retention.hours=2147483647
That's roughly 245,000 years. I believe I tried -1
at some point, but using the max value worked. Perhaps log.retention.ms
accepts different values, but regardless -- the second of your configuration options should be sufficient. My guess is neither option is necessary; either would be sufficient. Certainly, the second one is sufficient by itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With