MirrorMaker 2 concept in Kafka - Commands & Configuration
clusters = source, target source.bootstrap.servers = source-kafka:9092 target.bootstrap.servers = target-kafka:9092 # Replication policy replication.policy.class = org.apache.kafka.connect.mirror.DefaultReplicationPolicy # Topics to replicate topics = .* # replicate all topics # Consumer and producer configs consumer.auto.offset.reset = earliest producer.acks = all # Enable heartbeats and offsets sync emit.heartbeats.enabled = true sync.topic.acls.enabled = true # Group ID for MirrorMaker 2 group.id = mirror-maker-group # Internal topics replication internal.topics = __consumer_offsets,__transaction_state # Number of tasks tasks.max = 1
This file configures MirrorMaker 2 to connect two Kafka clusters named 'source' and 'target'.
clusters: lists the cluster aliases.
source.bootstrap.servers and target.bootstrap.servers: specify the Kafka servers for each cluster.
replication.policy.class: defines how topic names are mapped during replication.
topics: regex to select which topics to replicate (here all topics).
consumer.auto.offset.reset and producer.acks: set consumer and producer reliability.
emit.heartbeats.enabled and sync.topic.acls.enabled: enable internal syncing features.
group.id: consumer group for MirrorMaker 2 tasks.
internal.topics: internal Kafka topics to replicate for consistency.
tasks.max: number of parallel tasks to run.
connect-mirror-maker.sh connect-mirror-maker.properties
kafka-topics.sh --bootstrap-server target-kafka:9092 --list--bootstrap-server - Specifies the Kafka server to connect to--list - Lists all topics on the clusterkafka-consumer-groups.sh --bootstrap-server target-kafka:9092 --describe --group mirror-maker-group--bootstrap-server - Specifies the Kafka server to connect to--describe - Shows detailed info about the consumer group--group - Specifies the consumer group to describeIf you remember nothing else from this pattern, remember: MirrorMaker 2 automatically copies Kafka topics between clusters to keep data in sync without manual effort.