:_mod-docs-content-type: CONCEPT

// Module included in the following assemblies:
//
// assembly-config.adoc

[id='con-config-mm2-multiple-instances-{context}']
= Configuring MirrorMaker 2 using a shared target Kafka cluster

[role="_abstract"]
MirrorMaker 2 runs on the Kafka Connect framework and uses internal Kafka topics to store configuration, offsets, and status information.

You can run multiple MirrorMaker 2 connectors in a single Kafka Connect cluster, for example to replicate data from multiple source Kafka clusters to the same target Kafka cluster.

When running multiple Kafka Connect clusters that replicate data to the same target Kafka cluster, you must configure unique Kafka Connect worker settings so that each cluster operates independently.

This requirement applies across all Kafka Connect–based deployments, including Kafka Connect and  MirrorMaker 2 instances that target the same Kafka cluster.

Kafka Connect identifies a worker cluster by its group ID and by the names of the internal topics it uses.
If multiple Kafka Connect clusters use the same values, they form a single Kafka Connect cluster and share internal state.

When deploying multiple Kafka Connect clusters against the same target Kafka cluster, configure unique values for the following Kafka Connect worker properties in each deployment:

* `group.id`
* `config.storage.topic`
* `offset.storage.topic`
* `status.storage.topic`

These settings are configured in the `.spec.target` section. 

[source,yaml,subs="attributes+"]
----
apiVersion: {KafkaMirrorMaker2ApiVersion}
kind: KafkaMirrorMaker2
metadata:
  name: my-mirror-maker2
spec:
  # Target / Connect cluster configuration (required)
  target:
    alias: "my-cluster-target"
    bootstrapServers: my-cluster-target-kafka-bootstrap:9092
    groupId: my-mirror-maker2-group # <1>
    configStorageTopic: my-mirror-maker2-config # <2>
    offsetStorageTopic: my-mirror-maker2-offset # <3>
    statusStorageTopic: my-mirror-maker2-status # <4>
  # ...
----
<1> The Kafka Connect cluster group ID within Kafka.
<2> Kafka topic that stores connector offsets.
<3> Kafka topic that stores connector and task status configurations.
<4> Kafka topic that stores connector and task status updates.

If multiple Kafka Connect clusters are deployed with the same worker group ID and internal topic names, they form a single Kafka Connect cluster and share internal state.
This can result in unexpected behavior and replication errors.

You do not need to change these settings when:

* Running multiple MirrorMaker 2 connectors in a single Kafka Connect cluster
* Replicating data from the same source Kafka cluster to different target Kafka clusters by using separate Kafka Connect clusters
* Deploying active-active replication, where each Kafka Connect cluster targets a different Kafka cluster
