问题描述
我正在本地计算机上使用Kafka,并且添加了以下主题配置:
I'm playing with Kafka in my local machine, and I have added the following Topic configuration:
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic topic1 config retention.ms=60000
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic topic1 —config file.delete.delay.ms=40000
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic topic1 --config segment.bytes=400000
我的理解是,当该段达到超出定义的段大小(segment.bytes = 400000)时,该段将被删除,再加上该段中的每条消息都超过了所定义的保留时间(retention.ms = 60000)
My understanding is a segment will be deleted when the segment reaches out the segment size above defined (segment.bytes=400000) PLUS every single message within the segment is older than the retention time above defined (retention.ms=60000).
我注意到只有35个字节的段,其中包含一条消息,在一分钟后被删除了(也许更多)
What I noticed is a segment of just 35 bytes, which conteined just one message, was deleted after the minute (maybe a little more)
我从哪里获得这些信息?摘自Linkedin工程师关于删除过程如何工作的帖子:
Where I get that information? from a post that a Linkedin Engineer made about how the deletion process works:
链接:保留的工作原理
推荐答案
您错过了解释某些引用的语句:
You miss interpret some of the statements you cite:
这显然表明旋转可以由大小或时间触发.是或,而不是和.
This clearly says rotation can be triggered by size or time. It's or, not and.
因此,在通过时间触发旋转关闭线段后,无论其大小如何都可以将其删除.
Thus, after a segment got closed by rotating triggered by time, it can be deleted regardless of its size.
这篇关于Kafka甚至会在达到分段大小之前删除分段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!