Kafka:偏移序列 [英] Kafka: Offset sequence
问题描述
发布的每条消息(假设消息被压缩)是否会分配一个唯一的偏移量#并在给定分区内保持顺序和增量?另外,offset#序列是否有可能自己重置,意味着它可以从0开始?
每个分区都是一个有序的、不可变的记录序列不断附加到——结构化的提交日志.中的记录每个分区都分配有一个称为偏移量的顺序 ID 号唯一标识分区内的每条记录.
消费者甚至可以从一开始就读取特定的偏移量:
为了重置特定消费者组的偏移量,您可以使用以下内容:
kafka-consumer-groups --bootstrap-server localhost:9092 --group my-group --reset-offsets --to-earliest --all-topics --execute
Will each message posted (assuming messages are compressed) have a unique offset# assigned and remain sequential and incremental within a given partition? Also, is it possible that the offset# sequence can reset itself, meaning it can start from 0?
Official documentation is quite clear on that:
For each topic, the Kafka cluster maintains a partitioned log that looks like this:
Each partition is an ordered, immutable sequence of records that is continually appended to—a structured commit log. The records in the partitions are each assigned a sequential id number called the offset that uniquely identifies each record within the partition.
Consumers are able to read from specific offsets even from the beginning:
In order to reset offsets for a particular consumer group you can use the following:
kafka-consumer-groups --bootstrap-server localhost:9092 --group my-group --reset-offsets --to-earliest --all-topics --execute
这篇关于Kafka:偏移序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!