question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How to attach MirrorMaker to and existing group.id in source?

See original GitHub issue

To migrate from MM1 to MM2 I would like to start MM2 read from where MM1 stopped. I tried to attach to the same consume group as MM1 read from. Here is my configuration:

apiVersion: kafka.strimzi.io/v1alpha1
kind: KafkaMirrorMaker2
metadata:
  name: strimzi-aws-to-dc
spec:
  replicas: 1
  connectCluster: "dc"
  clusters:
  - alias: "dc"
    bootstrapServers: dc:9092
  - alias: "aws"
    bootstrapServers: aws:9092
    config:
      group.id: aws-to-dc-stg-group
  mirrors:
  - targetCluster: "dc"
    sourceCluster: "aws"
    sourceConnector:
      config:
        group.id: aws-to-dc-stg-group
    topicsPattern: "mm1-switch-mm2"
    groupsPattern: "aws-to-dc-stg-group"

When I run kubectl describe deployments I see that Kafka connect uses the default group:

...
    Environment:
      KAFKA_CONNECT_CONFIGURATION:      config.storage.topic=mirrormaker2-cluster-configs
                                        group.id=mirrormaker2-cluster
                                        status.storage.topic=mirrormaker2-cluster-status
                                        config.providers.file.class=org.apache.kafka.common.config.provider.FileConfigProvider
                                        offset.storage.topic=mirrormaker2-cluster-offsets
                                        config.providers=file
                                        value.converter=org.apache.kafka.connect.converters.ByteArrayConverter
                                        key.converter=org.apache.kafka.connect.converters.ByteArrayConverter
...

In MM2 logs I also see that it does not use groupId what expected:

...
2020-06-26 15:16:55,940 INFO ConsumerConfig values:
...
	group.id = null
	group.instance.id = null
...
2020-06-26 15:16:56,076 INFO [Consumer clientId=consumer-4, groupId=null] Subscribed to partition(s): mm1-switch-mm2-0 (org.apache.kafka.clients.consumer.KafkaConsumer) [task-thread-aws->dc.MirrorSourceConnector-0]
2020-06-26 15:16:56,077 INFO Starting with 0 previously uncommitted partitions. (org.apache.kafka.connect.mirror.MirrorSourceTask) [task-thread-aws->dc.MirrorSourceConnector-0]
2020-06-26 15:16:56,078 INFO [Consumer clientId=consumer-4, groupId=null] Seeking to offset 10 for partition mm1-switch-mm2-0 (org.apache.kafka.clients.consumer.KafkaConsumer) [task-thread-aws->dc.MirrorSourceConnector-0]
2020-06-26 15:16:56,078 INFO task-thread-aws->dc.MirrorSourceConnector-0 replicating 1 topic-partitions aws->dc: [mm1-switch-mm2-0]. (org.apache.kafka.connect.mirror.MirrorSourceTask) [task-thread-aws->dc.MirrorSourceConnector-0]
2020-06-26 15:16:56,078 INFO WorkerSourceTask{id=aws->dc.MirrorSourceConnector-0} Source task finished initialization and start (org.apache.kafka.connect.runtime.WorkerSourceTask) [task-thread-aws->dc.MirrorSourceConnector-0]
2020-06-26 15:16:56,085 INFO [Consumer clientId=consumer-4, groupId=null] Cluster ID: olRs7ybdTU--T9NXZvIbSw (org.apache.kafka.clients.Metadata) [task-thread-aws->dc.MirrorSourceConnector-0]

Please advise how to attach to the consumer group.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
yupyvovarovcommented, Jun 30, 2020

Already found the answer. I missed is that Kafka is a key/value system. So the solution is quite simple:

  1. Create mirrormaker2-cluster-offsets topic in destination side: $ ./kafka-topics.sh --bootstrap-server kafka-dc:9092 --create --replication-factor 1 --partitions 1 --topic mirrormaker2-cluster-offsets --config "cleanup.policy=compact"
  2. Populate topic with requared offset: $ ./kafka-console-producer.sh --bootstrap-server kafka-dc:9092 --topic mirrormaker2-cluster-offsets --property parse.key=true --property key.separator="|" ["aws->dc.MirrorSourceConnector",{"cluster":"aws","partition":0,"topic":"mm1-switch-mm2"}]|{"offset":21}
  3. Start MM2.

MM2 will start replication from the defined offset.

2reactions
scholzjcommented, Jun 30, 2020

Thanks for updating the case with the solution! That is always great to have it here for record. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

A look inside Kafka Mirrormaker 2 - Cloudera Blog
Internally the Kafka Connect framework assumes that a source connector reads from an external source and writes to Kafka while a sink connector ......
Read more >
Migrate from MirrorMaker to Replicator
The src.consumer.group.id in Replicator must match group.id in MirrorMaker. Stop the running MirrorMaker instance in DC1, where <mm pid> is the MirrorMaker ......
Read more >
How to Deploy Kafka MirrorMaker with an Existing ...
Ensure that your group.id names are not the same. Open the PAConsumerConfig file and change the zookeeper connection and bootstrap servers in ...
Read more >
Kafka MirrorMaker2 - not mirroring consumer group offsets
Started a consumer group in the source cluster. Consumed few messages and stopped it. Posted new messages in this topic and mirror maker...
Read more >
KIP-382: MirrorMaker 2.0 - Apache Software Foundation
The existing MirrorMaker source will be removed from Kafka core project. MM2 will be added to the connect project under a new module...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found