mkdir -p ~/temp
cd ~/temp
# Clone sample code
git clone https://github.com/debezium/debezium-examples.git
cd ./debezium-examples/tutorial
alias docker-compose="docker compose"
# Start the topology as defined in https://debezium.io/documentation/reference/stable/tutorial.html
export DEBEZIUM_VERSION=2.0
docker-compose -f docker-compose-sqlserver.yaml up -d
# Initialize database and insert test data
cat debezium-sqlserver-init/inventory.sql | docker-compose -f docker-compose-sqlserver.yaml exec -T sqlserver bash -c '/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD'
# Start SQL Server connector
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" http://localhost:8083/connectors/ -d @register-sqlserver.json
Stream the Kafka messages:
# Consume messages from a Debezium topic
docker-compose -f docker-compose-sqlserver.yaml exec kafka /kafka/bin/kafka-console-consumer.sh \
--bootstrap-server kafka:9092 \
--from-beginning \
--property print.key=true \
--topic server1.testDB.dbo.customers
Open a connection to the SQL Server (SSMS / Azure Data Studio / SqlCmd / ...) run SQL commands there.
Cleanup script:
# Shut down the cluster
docker-compose -f docker-compose-sqlserver.yaml down