This example demonstrates how to deploy Debezium Server using Postgres, MongoDB, and MySQL as data sources and Google Cloud Pub/Sub as a destination.
Note: Running this example may incur costs for managed Google Cloud services. Be sure to delete all resources once you've completed the example
This demo shows how to use Debezium Server with data sources such as Postgres, MongoDB, and MySQL. It sends data to Google Cloud Pub/Sub. We deploy the source databases using a Docker Compose file, and the Pub/Sub topic is hosted on the Google Cloud Platform.
Before getting started, ensure you have the following prerequisites:
- Docker
- A GCP service account with the
pubsub.publisherrole - A Pub/Sub topic
- The gcloud client installed
└── debezium-server-sink-pubsub
├── README.md
├── config-mongodb
│ └── application.properties
├── config-mysql
│ └── application.properties
├── config-postgres
│ └── application.properties
└── docker-compose.yml
README.mdis an essential guide for this example.config-mongodb/application.propertiesMongoDB configuration of the Debezium Connector.config-postgres/application.propertiesPostgres configuration of the Debezium Connector.config-mysql/application.propertiesMySQL configuration of the Debezium Connector.docker-compose.ymlis used for defining and running Debezium Server and the databases via Docker Compose.
- Edit the
docker-compose.ymlfile and replace/your/path/to/service-account.jsonwith the GCP Service Account path on your local machine. - Create a GCP Pub/Sub topic. From the terminal, create a Pub/Sub topic:
gcloud pubsub topics create tutorial.inventory.customers- Export environment variable:
export DEBEZIUM_VERSION=2.3- Edit the Debezium configurations:
- For PostgresSQL, Edit the
config-postgres/application.propertiesfile, and replaceproject-idwith your GCP project id - For MongoDB, Edit the
config-mongodb/application.propertiesfile, and replaceproject-idwith your GCP project id - For MySQL, Edit the
config-mongodb/application.propertiesfile, and replaceproject-idwith your GCP project id
Start the database container:
docker compose up -d postgresStart the Debezium Server:
docker compose up -d debezium-server-postgresTest the setup by making changes to the customers table. The logs will appear in Google Cloud Pub/Sub shortly. You can access Postgres with this command:
docker compose exec postgres env PGOPTIONS="--search_path=inventory" bash -c 'psql -U $POSTGRES_USER postgres'Start the database container:
docker compose up -d mongodb mongodb-initStart Debezium Server:
docker compose up -d debezium-server-mongodbStart the database container:
docker compose up -d mysqlStart Debezium Server:
docker compose up -d debezium-server-mysqlTest the setup by making changes to the customers table. The logs will appear in Google Cloud Pub/Sub shortly. You can access MySQL with this command:
docker compose exec mysql bash -c 'mysql -u $MYSQL_USER -p$MYSQL_PASSWORD'