- https://debezium.io/documentation/reference/stable/tutorial.html">Start the topology as defined in https://debezium.io/documentation/reference/stable/tutorial.html
- Start Postgres connector
- Consume messages from a Debezium topic
- Modify records in the database via Postgres client
- update record
- delete record
- Shut down the cluster
下载 ebezium-examples 仓库
git clone https://github.com/debezium/debezium-examples.git
切换到 tutorial 目录下
cd debezium-examples/tutorial
使用 Debezium 同步 Postgres 到 Kafka ```bash
Start the topology as defined in https://debezium.io/documentation/reference/stable/tutorial.html
export DEBEZIUM_VERSION=1.8 docker-compose -f docker-compose-postgres.yaml up
Start Postgres connector
curl -i -X POST -H “Accept:application/json” -H “Content-Type:application/json” http://localhost:8083/connectors/ -d @register-postgres.json
Consume messages from a Debezium topic
docker-compose -f docker-compose-postgres.yaml exec kafka /kafka/bin/kafka-console-consumer.sh \ —bootstrap-server kafka:9092 \ —from-beginning \ —property print.key=true \ —topic dbserver1.inventory.customers
Modify records in the database via Postgres client
docker-compose -f docker-compose-postgres.yaml exec postgres env PGOPTIONS=”—search_path=inventory” bash -c ‘psql -U $POSTGRES_USER postgres’
update record
UPDATE customers SET first_name=’Anne Marie’ WHERE id=1004;
delete record
DELETE FROM customers WHERE id=1004;
Shut down the cluster
docker-compose -f docker-compose-postgres.yaml down ```