首页 > 解决方案 > 尽管 log.retention.hours=168 昨天发送的消息的日志文件不存在

问题描述

昨天我在我的 Ubuntu 18.04.01 服务器版中安装了 Kafka 2.0 并按照 QuickStart 说明和解释,直到成功部署第 7 步:https ://kafka.apache.org/quickstart

今天我发现 /tmp 中没有 kafka-logs- 文件,尽管在相关的 server.properties 文件中直接明确了:

server.properties :
# A comma separated list of directories under which to store log files
 log.dirs=/tmp/kafka-logs
# The minimum age of a log file to be eligible for deletion due to age
log.retention.hours=168

 server-1.properties :
# A comma separated list of directories under which to store log files
log.dirs=/tmp/kafka-logs-1
# The minimum age of a log file to be eligible for deletion due to age
log.retention.hours=168

server-2.properties :
# A comma separated list of directories under which to store log files
log.dirs=/tmp/kafka-logs-2
# The minimum age of a log file to be eligible for deletion due to age
log.retention.hours=168

尽管成功地跟进了快速入门教程的前七个步骤,为什么会发生这种情况?以及如何保存 Kafka 日志文件,其中包含通过 Kafka 代理在生产者和接收者之间发送的消息?

期待您的帮助。马可

标签: loggingapache-kafkaretention

解决方案


Since your log.dirs is pointing to /tmp directory, it will wipe everything on system reboot. Same applies for Zookeeper data.dir also.

Make sure that these directories are not pointing to the tmp folder.

Also, there is one more attribute log.retention.bytes along with log.retention.hours which is useful for log compaction.

It denotes the maximum size of logs before deleting it. By default, it is -1. Hence logs can be retained based on retention time. If it is configured to any specific numbers, beyond that it will delete the logs.


推荐阅读