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

查看:79
本文介绍了如何确保将日志永久保留在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#configuration log.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天全站免登陆