Skip to content

Instantly share code, notes, and snippets.

@dollarkillerx
Last active April 15, 2021 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dollarkillerx/77f89729749d2bf6309a5f04b7224bd7 to your computer and use it in GitHub Desktop.
Save dollarkillerx/77f89729749d2bf6309a5f04b7224bd7 to your computer and use it in GitHub Desktop.
debezium mysql cdc

1.debezium创建监听用户

CREATE USER 'debezium_test'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxx'; # 此处天坑
GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'debezium_test'@'%';
GRANT ALL PRIVILEGES ON datapack_fund_and_institution.* TO 'debezium_test'@'%';
GRANT ALL PRIVILEGES ON dataapp_fund_and_institution.* TO 'debezium_test'@'%';
GRANT ALL PRIVILEGES ON delta_fund_and_institution.* TO 'debezium_test'@'%';
GRANT ALL PRIVILEGES ON amac_service.* TO 'debezium_test'@'%';
GRANT ALL PRIVILEGES ON dbv5.* TO 'debezium_test'@'%';
FLUSH PRIVILEGES;

mysql8 默认使用 sha256_password 方式身份验证,这种验证方式需要在数据库连接上添加 allowPublicKeyRetrieval=true 参数,而 debezium 没有添加,所以连接数据库时会报错。所以在使用 mysql8 时我们需要指定使用 mysql_native_password 方式身份验证

2.注册 connector

  • 注册 任意 但要见名知意
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" 127.0.0.1:8083/connectors/ -d '{
    "name": "dp_enterprise_dev",  # 任意
    "config": {
        "connector.class": "io.debezium.connector.mysql.MySqlConnector",
        "tasks.max": "1",
        "database.hostname": "127.0.0.1",
        "database.port": "3306",
        "database.user": "debezium",
        "database.password": "xxxx",
        "database.server.id": "184054",       # 任意
        "database.server.name": "dp_enterprise",  # 任意
        "database.whitelist": "alignment", # 监听DB
        "database.history.kafka.bootstrap.servers": "kafka1:9092",  # kafka地址
        "database.history.kafka.topic": "dp_enterprise_dev"  # 任意
    }
}'
  • 检查是否注册成功
curl -H "Accept:application/json" 172.23.0.21:8083/connectors/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment