Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replicating messages from one Kafka topic to another kafka topic

Tags:

apache-kafka

I want to make a flow from a Kafka cluster/topic in thr prod cluster into another Kafka cluster in the dev environment for scalability and regrrssion testing.

For the duck-tape solution, I cascade a Kafka consumer and producer, but my instinct tells me that there should be a better way. But, I couldn't find any good solution yet. Can anyone help me?

like image 772
Sewook Wee Avatar asked May 09 '16 14:05

Sewook Wee


People also ask

How do I copy a message from one Kafka topic to another?

Click on a source topic, select target topic, and click “Start Copying” button. That's it. Kafka Magic will try copying up to 'Max Results' messages from source to target using default schema assignments for the topics.

How do I copy data from one Kafka cluster to another?

The process of replicating data between Kafka clusters is called "mirroring", to differentiate cross-cluster replication from replication among nodes within a single cluster. A common use for mirroring is to maintain a separate copy of a Kafka cluster in another data center.

What is topic replication in Kafka?

Topic Replication is the process to offer fail-over capability for a topic. Replication factor defines the number of copies of a topic in a Kafka cluster. Replication factor can be defined at topic level.

Can Kafka consume from another Kafka?

Yes, Kafka's design allows consumers from one consumer group to consume messages from multiple topics. The protocol underlying consumer.


1 Answers

If you want to replicate data from one cluster to another then there is one kafka tool called MirrorMaker.

Kafka comes with a tool for mirroring data between Kafka clusters. The tool reads from a source cluster and writes to a destination cluster. Data will be read from topics in the source cluster and written to a topic with the same name in the destination cluster.

Here is syntax to run MirrorMaker tool:

bin/kafka-run-class.sh kafka.tools.MirrorMaker
       --consumer.config consumer.properties
       --producer.config producer.properties --whitelist my-topic

You can find this script in kafka installation directory. Here you need to provide consumer.properties of your source cluster and producer.properties of your destination cluster. You can whitelist which topics should be mirrored through --whitelist option.

You can find more information about Mirroring data between clusters

Note: MirrorMaker copies data into same topic_name in destination cluster as source cluster

like image 139
avr Avatar answered Sep 28 '22 06:09

avr