凡科网站可以做自适应的吗,域名没过期 网站打不开怎么办,响应式网页,成都网站建设推来客网站系统目录 一、offset的默认维护位置1.1、offset的默认维护位置概述1.2、offset的默认维护位置图解 二、消费者offset的案例 一、offset的默认维护位置
1.1、offset的默认维护位置概述
Kafka0.9版本之前#xff0c;consumer默认将offset保存在Zookeeper中。从Kafka0.9版本开始consumer默认将offset保存在Zookeeper中。从Kafka0.9版本开始consumer默认将offset保存在Kafka一个内置的topic中该topic为__consumer_offsets__consumer_offsets 主题里面采用 key 和 value 的方式存储数据。key 是 group.idtopic分区号value 就是当前 offset 的值。每隔一段时间kafka 内部会对这个 topic进行compact也就是每个 group.idtopic分区号就保留最新数据。__consumer_offsets 为 Kafka 中的 topic那就可以通过消费者进行消费。
1.2、offset的默认维护位置图解 二、消费者offset的案例 在配置文件 config/consumer.properties 中添加配置 exclude.internal.topicsfalse默认是 true表示不能消费系统主题。为了查看该系统主题数据所以该参数修改为 false。 重启kafka服务。 采用命令行方式创建一个新的 topic。 bin/kafka-topics.sh --bootstrap-server 192.168.136.27:9092 --create --partitions 2 --replication-factor 2 --topic offsetTopic启动生产者往 offsetTopic 生产数据。 bin/kafka-console-producer.sh --bootstrap-server 192.168.136.27:9092 --topic offsetTopic启动消费者消费 offsetTopic 数据。 注意指定消费者组名称更好观察数据存储位置key 是 group.idtopic分区号。 bin/kafka-console-consumer.sh --bootstrap-server 192.168.136.27:9092 --topic offsetTopic --group test查看消费者消费主题__consumer_offsets。 bin/kafka-console-consumer.sh --topic __consumer_offsets --bootstrap-server 192.168.136.29:9092 --consumer.config config/consumer.properties --formatter kafka.coordinator.group.GroupMetadataManager\$OffsetsMessageFormatter --from-beginning