Debezium MySQL错误:连接密码为空

Posted

技术标签:

【中文标题】Debezium MySQL错误:连接密码为空【英文标题】:Debezium MySQL Error: The connection password is empty 【发布时间】:2019-07-30 08:05:42 【问题描述】:

我的 Debezium 连接器有以下 docker-compose.yml 配置:

    version: '3.1'

    services:

    db:
        image: mysql
        network_mode: host
        environment:
        MYSQL_ROOT_PASSWORD: 123456
        volumes:
        - ./mysql.cnf:/etc/mysql/conf.d/mysql.cnf
        ports:
        - 3306:3306
        container_name: mydb

    zookeeper:
        image: confluentinc/cp-zookeeper
        network_mode: host
        ports:
        - "2181:2181"
        environment:
        ZOOKEEPER_CLIENT_PORT: 2181
        container_name: myzookeeper

    kafka:
        image: confluentinc/cp-kafka
        network_mode: host
        depends_on:
        - zookeeper
        - db
        ports:
        - "9092:9092"
        environment:
        KAFKA_ZOOKEEPER_CONNECT: localhost:2181
        KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
        KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
        KAFKA_BROKER_ID: 1
        KAFKA_MIN_INSYNC_REPLICAS: 1
        container_name: mykafka

    connector:
        image: debezium/connect:0.10
        network_mode: host
        ports:
        - "8083:8083"
        environment:
        GROUP_ID: 1
        CONFIG_STORAGE_TOPIC: my_connect_configs
        OFFSET_STORAGE_TOPIC: my_connect_offsets
        BOOTSTRAP_SERVERS: localhost:9092
        HOST_NAME: localhost
        depends_on:
        - zookeeper
        - db
        - kafka
        container_name: myconnector

当我想创建连接器时,我收到以下错误:

    curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" localhost:8083/connectors/ -d ' "name": "mystore-connector", "config":  "connector.class": "io.debezium.connector.mysql.MySqlConnector", "tasks.max": "1", "database.hostname": "localhost", "database.port": "3306", "database.user": "morteza", "database.password": "morteza_password", "database.server.id": "223344", "database.server.name": "dbserver1", "database.whitelist": "mystore", "database.history.kafka.bootstrap.servers": "localhost:9092", "database.history.kafka.topic": "dbhistory.mystore"  '
    HTTP/1.1 400 Bad Request
    Date: Fri, 08 Mar 2019 09:48:34 GMT
    Content-Type: application/json
    Content-Length: 255
    Server: Jetty(9.4.12.v20180830)

    "error_code":400,"message":"Connector configuration is invalid and contains the following 1 error(s):\nUnable to connect: Public Key Retrieval is not allowed\nYou can also find the above list of errors at the endpoint `/connectorType/config/validate`"       

而 Debezium 连接器显示此错误:

    The connection password is empty   [io.debezium.connector.mysql.MySqlConnector]
    myconnector  | 2019-03-08 09:38:26,755 INFO   ||  Failed testing connection for jdbc:mysql://localhost:3306/?useInformationSchema=true&nullCatalogMeansCurrent=false&useSSL=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=CONVERT_TO_NULL with user 'morteza'   [io.debezium.connector.mysql.MySqlConnector]

如您所见,我已设置字段database.password 的值,但我收到数据库密码错误。

【问题讨论】:

Public Key Retrieval is not allowed是创建POST返回的错误。 this thread 中的一些建议可能值得一试。其中一个建议是它只是一个无效的用户名/密码组合 这是Debezium with MySQL 和docker-compose 的示例,如果对您的配置进行尝试有用的话。 Robin,即使使用 root 并通过 123456,我也收到了同样的错误。 我认为问题出在这条消息Public Key Retrieval is not allowed。 IIRC 过去当有人使用 SSL 时,JDBC 驱动程序和 MySQL 驱动程序版本之间存在兼容性问题。请参阅例如community.atlassian.com/t5/Confluence-questions/… @JiriPechanec 谢谢。我将mysql版本更改为5.7,设置image: mysql:5.7,它工作正常!我想知道为什么它没有被支持。我在debezium.io/blog/2018/12/19/debezium-0-9-0-beta2-released 发现 debezium 0.9 将支持 mysql 8。顺便问一下,您能否发布您的答案,以便其他用户可以在类似情况下使用它? 【参考方案1】:

当源 MySQL 数据库中的用户没有被授予所需的权限时,Debezium 0.9 可能会出现此错误 (Public Key Retrieval is not allowed)。在 Debezium 0.8 中,错误为 Unable to connect: Communications link failure

我在这里写了一个quick blog 关于这个问题,因为我遇到了这个问题并且错误消息有点不明显:)

tl;博士:ALTER USER 'debezium'@'%' IDENTIFIED WITH mysql_native_password BY 'dbz';

【讨论】:

我正在使用camel debezium mysql插件,它使用debezium connectro版本1.3.1.Final,显然它没有这个属性database.allowPublicKeyRetrieval 链接已损坏。顺便说一句,如果您可以在此处发布解决方案,那就太好了。 感谢@MuhammadWaqasDilawar,已修复【参考方案2】:

正如 Jiri Pechanec 所建议的,我在 docker-compose.yml 文件中将 image: mysql 更改为 image: mysql:5.7,现在它可以正常工作了。

【讨论】:

以上是关于Debezium MySQL错误:连接密码为空的主要内容,如果未能解决你的问题,请参考以下文章

Kafka 生产者创建 Debezium MySQL 连接器后无法创建主题并引发连续错误

Debezium - MySQL 连接器 - Kinesis - 服务未启动

MySQL 的 Debezium 刷新超时和 OutOfMemoryError 错误

mysql 忘记密码,重置密码,mysql.user表为空的解决办法

mysql连接错误

Linux下MySQL拒绝连接