【问题标题】:Kafka Mirror Maker 2 Offset Replication Not WorkingKafka Mirror Maker 2 偏移复制不工作
【发布时间】:2020-09-23 16:49:21
【问题描述】:

我们正在测试 kafka 的 DR 场景。我们在不同的区域有 2 个 kafka 集群。我们正在使用 MirrorMaker2 来复制主题和消息。 主题和消息能够复制。但是我们观察到偏移量没有复制。

例如 从生产者那里产生了 10 条指向 kafka 区域 1 的消息。

从消费者那里消费了 5 条指向 kafka 区域 1 的消息

停止消费者指向 region1

开始消费者指向 region2

消费消息

这里的期望是区域 2 的消费者应该从偏移量 6 开始消费

但它从偏移量 0 开始消耗

下面是属性文件

 clusters = primary, secondary
# primary cluster information
 primary.bootstrap.servers = test1-primary.com:9094,test2-primary.com.apttuscloud.io:9094,test3-primary.com:9094
 primary.security.protocol= SASL_SSL
 primary.ssl.truststore.password= dummypassword
 primary.ssl.truststore.location= /opt/bitnami/kafka/config/certs/kafka.truststore.jks
 primary.ssl.keystore.password= dummypassword
 primary.ssl.keystore.location= /opt/bitnami/kafka/config/certs/kafka.keystore.jks
 primary.ssl.endpoint.identification.algorithm=
 primary.sasl.mechanism= PLAIN
 primary.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="dummyuser" password="dummypassword";

# secondary cluster information
 secondary.bootstrap.servers = test1-secondary.com:9094,test2-secondary.com.apttuscloud.io:9094,test3-secondary.com:9094
 secondary.security.protocol= SASL_SSL
 secondary.ssl.truststore.password= dummypassword
 secondary.ssl.truststore.location= /opt/bitnami/kafka/config/certs/kafka.truststore.jks
 secondary.ssl.keystore.password= dummypassword
 secondary.ssl.keystore.location= /opt/bitnami/kafka/config/certs/kafka.keystore.jks
 secondary.ssl.endpoint.identification.algorithm=
 secondary.sasl.mechanism=PLAIN
 secondary.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="dummyuser" password="dummypassword";
# Topic Configuration
 primary->secondary.enabled = true
 primary->secondary.topics = .*

 secondary->primary.enabled = true
 secondary->primary.topics = .*

############################# Internal Topic Settings  #############################
# The replication factor for mm2 internal topics "heartbeats", "B.checkpoints.internal" and
# "mm2-offset-syncs.B.internal"
# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3
 checkpoints.topic.replication.factor= 3
 heartbeats.topic.replication.factor= 3
 offset-syncs.topic.replication.factor= 3

# The replication factor for connect internal topics "mm2-configs.B.internal", "mm2-offsets.B.internal" and
# "mm2-status.B.internal"
# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.
 offset.storage.replication.factor=3
 status.storage.replication.factor=3
 config.storage.replication.factor=3

 replication.factor = 3
 refresh.topics.enabled = true
 sync.topic.configs.enabled = true
 refresh.topics.interval.seconds = 10
 topics.blacklist = .*[\-\.]internal, .*\.replica, __consumer_offsets
 groups.blacklist = console-consumer-.*, connect-.*, __.*
 primary->secondary.emit.heartbeats.enabled = true
 primary->secondary.emit.checkpoints.enabled = true

请注意,一些机密值与虚拟值放在一起

问候,

纳伦德拉·贾达夫

【问题讨论】:

  • 你运行的是哪个版本?
  • 嗨,Mickael,您要询问的是哪个组件的版本。 Kafka 还是 Mirror Maker 2?
  • 你能指定你使用的MirrorMaker2的版本吗?
  • 嗨@MickaelMaison 我们使用的是2.5.0

标签: apache-kafka apache-kafka-mirrormaker


【解决方案1】:

使用 MirrorMaker 2.5,在集群之间移动消费者时,不会自动转换偏移量。

所以在另一个集群上启动消费者时,消费者需要使用RemoteClusterUtils.translateOffsets() 来找到他们在这个集群中的偏移量。

在 2.7(预计 2020 年 11 月)中,您可以让 MirrorMaker 2 自动转换偏移量,请参阅 https://cwiki.apache.org/confluence/display/KAFKA/KIP-545%3A+support+automated+consumer+offset+sync+across+clusters+in+MM+2.0

【讨论】:

  • 嗨@mickael-maison,RemoteClusterUtils 似乎只适用于基于java 的消费者,有人可以通过.net 等其他客户端实现它吗?某种可以执行的配置或步骤仅供参考,我们使用的是 Confluent.Kafka nuget 版本 1.5.1
  • RemoteClusterUtils 仅在 Java 中可用。您可以等待 2.7,也可以用您需要的语言重新实现它。逻辑(github.com/apache/kafka/blob/trunk/connect/mirror-client/src/…)实际上非常简单
猜你喜欢
  • 2020-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多