Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Replicating Data Between Two Kafka Clusters

Kafka can be deployed in mutliple data centers in an "Active-Active", "Active-Passive", or centralized architecture. In this hands-on lab, we simulate an active-passive architecture in which data from one cluster is replicated to another cluster using a tool called Replicator. Replicator, like MirrorMaker, allows you to preserve topic configuration in the source cluster while replicating the messages from one cluster to another.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 10, 2025
Duration
1h 45m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Start the Destination Cluster

    Note: After connecting via ssh, please give the lab extra time to finish provisioning. If you get a dpkg frontend lock message when running sudo apt install -y default-jdk, please give the lab more time before retrying the command.

    Start Zookeeper.

    bin/zookeeper-server-start etc/kafka/zookeeper.properties
    

    Start Kafka.

    bin/kafka-server-start etc/kafka/server.properties
    
  2. Challenge

    Start the Origin Cluster

    Make a copy of the configuration files.

    cp etc/kafka/zookeeper.properties /tmp/zookeeper_origin.properties
    cp etc/kafka/server.properties /tmp/server_origin.properties
    

    Change the port numbers for the origin cluster.

    sed -i -e "s/2181/2171/g" /tmp/zookeeper_origin.properties
    sed -i -e "s/9092/9082/g" /tmp/server_origin.properties
    sed -i -e "s/2181/2171/g" /tmp/server_origin.properties
    sed -i -e "s/#listen/listen/g" /tmp/server_origin.properties
    

    Change the data directory for the origin cluster.

    sed -i -e "s/zookeeper/zookeeper_origin/g" /tmp/zookeeper_origin.properties
    sed -i -e "s/kafka-logs/kafka-logs-origin/g" /tmp/server_origin.properties
    

    Start Zookeeper.

    bin/zookeeper-server-start /tmp/zookeeper_origin.properties
    

    Start Kafka.

    bin/kafka-server-start /tmp/server_origin.properties
    
  3. Challenge

    Create a Topic in the Source Cluster

    Create a topic named test-topic with 1 partition and a replication factor of 1.

    bin/kafka-topics --create --topic test-topic --replication-factor 1 --partitions 1 --zookeeper localhost:2171
    
  4. Challenge

    Run the Replicator Tool

    Run Kafka Connect in Standalone Mode and pass in the quickstart-replicator.properties file

    bin/connect-standalone etc/kafka/connect-standalone.properties etc/kafka-connect-replicator/quickstart-replicator.properties
    
  5. Challenge

    Produce and Verify Replication

    Verify that the topic was replicated to the destination cluster.

    bin/kafka-topics --describe --topic test-topic.replica --zookeeper localhost:2181
    

    Open a Console Producer and write to the topic test-topic in the source cluster.

    seq 10000 | bin/kafka-console-producer --topic test-topic --broker-list localhost:9082
    

    Confirm the messages were replicated by opening a console consumer to the destination cluster.

    bin/kafka-console-consumer --from-beginning --topic test-topic.replica --bootstrap-server localhost:9092
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight