连接docker到mysql数据库

mefy6pfw  于 2021-06-08  发布在  Kafka
关注(0)|答案(1)|浏览(656)

我是debezium的新手,正在尝试将我的kafka连接器连接到我的wamp服务器上已经存在的mysql数据库。
我根据教程文档启动了zookeeper和kafka,然后启动了kafka连接器。在我的postman中,我将以下json发送到我的kafka连接器,但我不断收到错误的请求响应。
启动Zookeper

docker run -it --rm --name zookeeper -p 2181:2181 -p 2888:2888 -p 3888:3888 debezium/zookeeper:0.7

开始Kafka

docker run -it --rm --name kafka -p 9092:9092 --link zookeeper:zookeeper debezium/kafka:0.7

启动Kafka连接器

docker run -it --rm --name connect -p 8083:8083 -e GROUP_ID=1 -e CONFIG_STORAGE_TOPIC=my_connect_configs -e OFFSET_STORAGE_TOPIC=my_connect_offsets --link zookeeper:zookeeper --link kafka:kafka debezium/connect:0.7

我用 Postman 发了以下邮件

{ "name": "shopcentra-connector", "config": { "connector.class": "io.debezium.connector.mysql.MySqlConnector", "tasks.max": "1", "database.hostname": "127.0.0.1", "database.port": "3306", "database.user": "root", "database.password": "root", "database.server.id": "5444", "database.server.name": "shopcentra", "database.whitelist": "shopcentra", "database.history.kafka.bootstrap.servers": "kafka:9092", "database.history.kafka.topic": "dbhistory.shopcentra", "include.schema.changes": "true" } }

我的坏React

{
"error_code": 400,
"message": "Connector configuration is invalid and contains the following 1 error(s):\nUnable to connect: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.\nYou can also find the above list of errors at the endpoint `/{connectorType}/config/validate`"
}
hsgswve4

hsgswve41#

如果您使用的是docker,那么可以使用预配置的mysql映像debezium/example mysql。或者,请确保为示例配置授予适当权限的用户:

GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT  ON *.* TO 'debezium' IDENTIFIED BY 'dbz';

还有每个数据库:

`GRANT ALL PRIVILEGES ON demo.* TO 'debezium'@'%';`

相关问题