From 11/20/2018, master branch is moved to branch-0.1. New master is backward-compatible.
=========
uReplicator provides the ability to replicate across Kafka clusters in other data centers. Instead of publishing to a single Kafka cluster, you can publish data to multiple regional Kafka clusters and aggregate it all in one Kafka cluster.
=========
Kafka's current (part of 0.8.2) MirrorMaker design consumes data from a given regional Kafka cluster using a Kafka high-level consumer. With this design, rebalancing in the high level consumer (due to a addition/deletion of topics, source cluster problems, network issues and so on) affects all the topics being replicated via that Mirrormaker.
Check out the uReplicator project:
git clone [email protected]:uber/uReplicator.git
cd uReplicator
This project contains everything (both mirrormaker-controller and mirrormaker-worker) you’ll need to run uReplicator.
Before you can run uReplicator, you need to build a package for it. This package is what your deployment tool uses to deploy uReplicator.
mvn clean package
Or command below (the previous one will take a long time to run):
mvn clean package -DskipTests
To test uReplicator locally, you need two systems: Kafka, and ZooKeeper. The script “grid” is to help you set up these systems.
chmod u+x bin/pkg/*.sh
bin/grid bootstrap
./bin/produce-data-to-kafka-topic-dummyTopic.sh
./deploy/kafka/bin/kafka-console-consumer.sh --zookeeper localhost:2181/cluster1 --topic dummyTopic
Kafka topic dummy topic data 1
Kafka topic dummy topic data 2
Kafka topic dummy topic data 3
Kafka topic dummy topic data 4
…
Example 1: Copy data from source cluster to destination cluster
./uReplicator-Distribution/target/uReplicator-Distribution-pkg/bin/start-controller-example1.sh
./uReplicator-Distribution/target/uReplicator-Distribution-pkg/bin/start-worker-example1.sh
curl -X POST -d '{"topic":"dummyTopic", "numPartitions":"1"}' http://localhost:9000/topics
./deploy/kafka/bin/kafka-console-consumer.sh --zookeeper localhost:2181/cluster2 --topic dummyTopic1
Kafka topic dummy topic data 1
Kafka topic dummy topic data 2
Kafka topic dummy topic data 3
Kafka topic dummy topic data 4
…
Example 2: Copy data from source Kafka to destination Kafka cluster without explicitly whitelisting topics
./uReplicator-Distribution/target/uReplicator-Distribution-pkg/bin/start-controller-example2.sh
./uReplicator-Distribution/target/uReplicator-Distribution-pkg/bin/start-worker-example2.sh
./deploy/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181/cluster2 --topic dummyTopic --partition 1 --replication-factor 1
./deploy/kafka/bin/kafka-console-consumer.sh --zookeeper localhost:2181/cluster2 --topic dummyTopic
Kafka topic dummy topic data 1
Kafka topic dummy topic data 2
Kafka topic dummy topic data 3
Kafka topic dummy topic data 4
…
When you’re done, you can clean everything up using the same grid script:
./bin/pkg/stop-all.sh
Congratulations! You’ve now set up a local grid that includes Kafka and ZooKeeper, and you've run a uReplicator worker on it.
Example 3: Run ureplicator on Docker
docker build -t devenv devenv/.
docker run -d -p 2181:2181 -p 9093:9093 -p 9094:9094 --add-host devenv:127.0.0.1 --name devenv devenv
docker build -t ureplicator .
docker run -d --link devenv:devenv -p 9000:9000 --name controller --expose=9000 ureplicator "controller" -mode customized \
-enableAutoWhitelist true \
-port 9000 \
-refreshTimeInSeconds 10 \
-srcKafkaZkPath devenv:2181/cluster1 \
-zookeeper devenv:2181 \
-destKafkaZkPath devenv:2181/cluster2 \
-helixClusterName testMirrorMaker
docker run -d --link devenv:devenv --name worker ureplicator "worker" \
--consumer.config example/example-consumer.properties \
--producer.config example/example-producer.properties \
--helix.config example/example-helix.properties
docker exec -it devenv bash
$KAFKA_HOME/bin/kafka-topics.sh --create --zookeeper localhost:2181/cluster2 --topic dummyTopic --partition 4 --replication-factor 1
docker exec -it devenv bash
./usr/kafka/produce-data-to-kafka-topic-dummyTopic.sh
docker exec -it devenv bash
$KAFKA_HOME/bin/kafka-console-consumer.sh --zookeeper localhost:2181/cluster2 --topic dummyTopic
Example 4 Run urepliator with 2 workers
docker-compose -f docker-compose-example4.yml build
docker-compose -f docker-compose-example4.yml up
docker exec -it ureplicator_devenv_1 bash;
./usr/kafka/produce-data-to-kafka-topic-dummyTopic.sh
docker exec -it ureplicator_devenv_1 bash;
$KAFKA_HOME/bin/kafka-topics.sh --create --zookeeper localhost:2181/cluster2 --topic dummyTopic1 --partition 4 --replication-factor 1
curl -X POST -d '{"topic":"dummyTopic", "numPartitions":"4"}' http://localhost:9000/topics
docker exec -it ureplicator_devenv_1 bash;
$KAFKA_HOME/bin/kafka-console-consumer.sh --zookeeper localhost:2181/cluster2 --topic dummyTopic1
curl localhost:9000/topics/dummyTopic | jq .
curl localhost:9000/instances | jq .
Content type
Image
Digest
Size
119.3 MB
Last updated
over 7 years ago
docker pull lshegll/kafka-ureplicator