Skip to content

Latest commit

 

History

History
89 lines (77 loc) · 2.09 KB

README.md

File metadata and controls

89 lines (77 loc) · 2.09 KB

CDC Service for MySQL

Prerequisite

Install
MySQL Config
  • log_bin should be ON
  • binlog_format should be ROW
  • binlog_row_image should be FULL
    SHOW VARIABLES LIKE 'log_bin';
    SHOW VARIABLES LIKE 'binlog_format';
    SHOW VARIABLES LIKE 'binlog_row_image';
    
  • database.user uses for cdc should have RELOAD or FLUSH_TABLES privilege(s).
  • binlog_rows_query_log_events=ON enable original query event in binlog.
Kafka Config

auto.create.topics.enable should be true

How to run

Start services
docker compose up -d
Create source connector
curl -i -X POST \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  localhost:8083/connectors/ \
  -d '{
    "name": "source-connector",
    "config": {
      "connector.class": "io.debezium.connector.mysql.MySqlConnector",
      "tasks.max": "1",
      "database.hostname": "mysql",
      "database.port": "3306",
      "database.user": "root",
      "database.password": "123456",
      "database.server.id": "184054",
      "topic.prefix": "mysql",
      "database.include.list": "coffee_shop",
      "schema.history.internal.kafka.bootstrap.servers": "kafka:9092",
      "schema.history.internal.kafka.topic": "schemahistory.coffee_shop"
    }
  }'
Start consumer
cd cdc-debezium-consumer
./gradlew run -d

Troubleshooting

Check status of Kafka Connect service
curl -H "Accept:application/json" localhost:8083/
Check available plugins
curl -s localhost:8083/connector-plugins
Check list connectors registered with Kafka Connect
curl -H "Accept:application/json" localhost:8083/connectors/

Delete a connector

curl -X DELETE localhost:8083/connectors/source-connector
Access the kafka container
docker exec -it cdc-debezium-consumer-kafka-1 /bin/bash 
cd bin
List kafka topic
kafka-topics.sh --list --bootstrap-server localhost:9092