如何确保日志在 Kafka 中永久保留? [英] How do I ensure that logs are retained forever in Kafka?

查看:49
本文介绍了如何确保日志在 Kafka 中永久保留?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要配置 Kafka 从不 来删除日志.查看他们的文档,我看到了两种控制这个的参数:

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.

日志保留"机制,在 http://kafka.apache 中描述.org/documentation.html#configurationlog.retention. 下.似乎设置 log.retention.ms = -1 表示无限保留.

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.

我的问题是:

这两种机制之间的关系是什么,只有这两种,以上设置是否足以防止日志被删除?

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?

推荐答案

不确定您使用的是哪个版本.对我来说,我用这个:

Not sure which version you are using. For me, I use this:

log.retention.hours=2147483647

那大约是 245,000 年.我相信我曾尝试过 -1 ,但使用最大值有效.也许 log.retention.ms 接受不同的值,但无论如何——您的第二个配置选项应该足够了.我的猜测是这两种选择都没有必要;要么就足够了.当然,第二个就足够了.

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.

这篇关于如何确保日志在 Kafka 中永久保留?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆