【发布时间】:2018-11-30 22:07:41
【问题描述】:
我是 debezium 的新手,正在尝试将我的 kafka 连接器连接到本地 WAMP 服务器上现有的 MySQL 数据库。
我根据教程文档启动了zookeeper和kafka,然后我启动了kafka connector。在我的邮递员中,我将以下 JSON 发送到我的 kafka 连接器,但我一直收到错误的请求响应。
启动 Zookepper
docker run -it --rm --name zookeeper -p 2181:2181 -p 2888:2888 -p 3888:3888 debezium/zookeeper:0.7
启动卡夫卡
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
使用我的 Post Man 我发送了以下内容
{ "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" } }
我的坏反应
{
"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`"
}
【问题讨论】:
-
database.hostname": "127.0.0.1"... 这意味着您的数据库正在连接容器中运行,但事实并非如此。您需要为主机使用您的外部 IP 地址 -
@cricket_007 但我在本地主机上运行 wamp,这是否意味着我无法连接到我的 wamp 本地主机?
-
您的容器有自己的网络堆栈。本地主机本身,而不是你的 wamp 环境。更多信息stackoverflow.com/questions/40746453/…和stackoverflow.com/a/43541681/2308683
-
另一种方法是将您的 WAMP 数据库迁移到 Mysql 容器中(或将所有 Apache、PHP 和 Mysql 作为容器运行)
-
@cricket_007 好的,如何将我的 wamp 数据库迁移到 mysql 容器中?以及我在该容器中所做的更改会在容器关闭后反映吗?
标签: mysql docker apache-kafka apache-kafka-connect debezium