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.
- Docker
- Docker Compose
- MySQL
- PostgreSQL
- Debezium
- Kafka
- Zookeeper
- Kafka Connect JDBC
- Kafka Connect Debezium
- Clone the repository
- Run the following command to start the services:
docker-compose up -d --build
- When the services are up and running, You can open makefile and run the following command to create the connectors:
make registry
- You can check the plugins running with the following command:
make plugins
- You can check the connectors running with the following command:
make connectors
- You can change the configuration of the connectors in the
.docker/debezium/connectors
directory. - You can change the configuration of the databases in the
.docker/postgres/config/postgres.cnf
and.docker/mysql/config/mysql.cnf
files. - You can change the configuration of the services in the
.docker/docker-compose.yml
file.
- Open Mysql Connection with the following command:
docker exec -it mysql_cdc /bin/sh -c "mysql -u root -p"
- Create a new database:
INSERT INTO a_profile(id, name,verified, mobile, email, created_at) values
(1, 'Amin', 'Y', '+989119119191', 'INFO@Ghaninia.ir', NOW());
- Open PostgreSQL Connection with the following command:
docker exec -it postgres_cdc /bin/sh -c "psql -U destination-db -d destination-db"
- Check the data in the
a_profile
table:
SELECT * FROM profiles;
-
You should see the data that you inserted in the MySQL database in the PostgreSQL database.
-
Down the services:
docker-compose down -v && docker volume prune