Code Monkey home page Code Monkey logo

mirror-maker-docker-example's Introduction

Objective

  1. Setup 2 kafka clusters : source & destination
  2. Create a topic on source with dummy data
  3. Run mirror-maker
  4. Verify the topic is created on destination with the corresponding data

Live action

sreencast

Kafka Clusters

  • source cluster* kafka-source, zookeeper-source
  • destination cluster : kafka-destination, kafka-destination

Topic to mirror

  • name : topic-to-mirror
  • data : sequence of the 10000 numbers
  topic-creation:
    image: confluentinc/cp-kafka:4.0.0
    command: bash -c "cub kafka-ready -z zookeeper-source:2181 1 30 && kafka-topics --zookeeper zookeeper-source:2181 --create --topic topic-to-mirror --partitions 10 --replication-factor 1"
    depends_on:
      - zookeeper-source

  dummy-generation:
    image: confluentinc/cp-kafka:4.0.0
    command: bash -c "cub kafka-ready -z zookeeper-source:2181 1 30 && sleep 5 && seq 10000 | kafka-console-producer --broker-list kafka-source:9092 --topic topic-to-mirror"
    depends_on:
      - zookeeper-source
      - kafka-source

Mirror maker

  mirror-maker:
    image: confluentinc/cp-kafka:4.0.0
    volumes:
      - ./consumer.cfg:/etc/consumer.cfg
      - ./producer.cfg:/etc/producer.cfg
    command: bash -c "cub kafka-ready -z zookeeper-source:2181 1 30 && cub kafka-ready -z zookeeper-destination:2181 1 30 && kafka-mirror-maker --consumer.config /etc/consumer.cfg --producer.config /etc/producer.cfg --whitelist topic-to-mirror --num.streams 1"
    depends_on:
      - kafka-source
      - kafka-destination
      - zookeeper-destination

consumer.cfg

bootstrap.servers=kafka-source:9092
exclude.internal.topics=true
group.id=mirror-maker
auto.offset.reset=earliest
partition.assignment.strategy=org.apache.kafka.clients.consumer.RoundRobinAssignor

producer.cfg

bootstrap.servers=kafka-destination:9092
acks=-1
batch.size=1
client.id=mirror_maker_producer
retries=2147483647
max.in.flight.requests.per.connection=1

Commands

$ docker-compose up -d
$ docker-compose ps

Wait for Zookeeper, Kafka, and dummy data producer to startup

$ docker-compose exec kafka-source kafka-topics --zookeeper zookeeper-source:2181 --list
$ docker-compose exec kafka-source kafka-console-consumer --bootstrap-server localhost:9092 --topic topic-to-mirror --from-beginning

Ok, we have our topic in the source cluster ready

$ docker-compose exec kafka-destination kafka-topics --zookeeper zookeeper-destination:2181 --list
$ docker-compose exec kafka-destination kafka-console-consumer --bootstrap-server localhost:9092 --topic topic-to-mirror --from-beginning

mirror-maker did replicate on the destination cluster

for demonstrating purposes use

docker-compose exec kafka-source kafka-console-producer --broker-list localhost:9092 --topic topic-to-mirror

and start typing

mirror-maker-docker-example's People

Contributors

framiere avatar richyp7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.