Skip to content

This repository demonstrates how to use Debezium for real-time data synchronization between two databases. It showcases a practical implementation of change data capture (CDC) to ensure that changes in one database are propagated to another seamlessly.

Notifications You must be signed in to change notification settings

ghaninia/harmonizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Debezium

Sync Database Source to Database Destination

Table of Contents

  1. Introduction
  2. Requirements
  3. Installation
  4. Configuration
  5. ManualTest

Introduction

This project is a simple example of how to use Debezium to sync data from one database to another. In this case, we are syncing data from the source-db database to the destination-db database. The source-db database is a MySQL database and the destination-db database is a PostgreSQL database.

Requirements

  • Docker
  • Docker Compose
  • MySQL
  • PostgreSQL
  • Debezium
  • Kafka
  • Zookeeper
  • Kafka Connect JDBC
  • Kafka Connect Debezium

Installation

  1. Clone the repository
  2. Run the following command to start the services:
docker-compose up -d --build
  1. When the services are up and running, You can open makefile and run the following command to create the connectors:
make registry
  1. You can check the plugins running with the following command:
make plugins
  1. You can check the connectors running with the following command:
make connectors

Configuration

  1. You can change the configuration of the connectors in the .docker/debezium/connectors directory.
  2. You can change the configuration of the databases in the .docker/postgres/config/postgres.cnf and .docker/mysql/config/mysql.cnf files.
  3. You can change the configuration of the services in the .docker/docker-compose.yml file.

ManualTest

  1. Open Mysql Connection with the following command:
docker exec -it mysql_cdc /bin/sh -c "mysql -u root -p"
  1. Create a new database:
INSERT INTO a_profile(id, name,verified, mobile, email, created_at) values
                                                       (1, 'Amin', 'Y', '+989119119191', 'INFO@Ghaninia.ir', NOW());
  1. Open PostgreSQL Connection with the following command:
docker exec -it postgres_cdc /bin/sh -c "psql -U destination-db -d destination-db"
  1. Check the data in the a_profile table:
SELECT * FROM profiles;
  1. You should see the data that you inserted in the MySQL database in the PostgreSQL database.

  2. Down the services:

docker-compose down -v && docker volume prune

About

This repository demonstrates how to use Debezium for real-time data synchronization between two databases. It showcases a practical implementation of change data capture (CDC) to ensure that changes in one database are propagated to another seamlessly.

Resources

Stars

Watchers

Forks

Packages

No packages published