- https://debezium.io/documentation/reference/stable/tutorial.html">Start the topology as defined in https://debezium.io/documentation/reference/stable/tutorial.html
- Initialize MongoDB replica set and insert some test data
- Start MongoDB connector
- Consume messages from a Debezium topic
- Modify records in the database via MongoDB client
- insert record
- Shut down the cluster
下载 ebezium-examples 仓库
git clone https://github.com/debezium/debezium-examples.git
切换到 tutorial 目录下
cd debezium-examples/tutorial
使用 Debezium 同步 MongoDB 到 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-mongodb.yaml up
Initialize MongoDB replica set and insert some test data
docker-compose -f docker-compose-mongodb.yaml exec mongodb bash -c ‘/usr/local/bin/init-inventory.sh’
Start MongoDB connector
curl -i -X POST -H “Accept:application/json” -H “Content-Type:application/json” http://localhost:8083/connectors/ -d @register-mongodb.json
Consume messages from a Debezium topic
docker-compose -f docker-compose-mongodb.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 MongoDB client
docker-compose -f docker-compose-mongodb.yaml exec mongodb bash -c ‘mongo -u $MONGODB_USER -p $MONGODB_PASSWORD —authenticationDatabase admin inventory’
insert record
db.customers.insert([ { _id : NumberLong(“1005”), first_name : ‘Bob’, last_name : ‘Hopper’, email : ‘thebob@example.com’, unique_id : UUID() } ]);
Shut down the cluster
docker-compose -f docker-compose-mongodb.yaml down ```