Debezium如何正确向Kafka Connect注册SqlServer连接器-连接被拒绝 [英] Debezium How do I correctly register the SqlServer connector with Kafka Connect - connection refused

查看:1169
本文介绍了Debezium如何正确向Kafka Connect注册SqlServer连接器-连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

如何在Kafka Connect中正确注册SqlServer连接器以连接到独立的SQL Server实例?注意:我不在Docker中运行SQL Server.

How do I correctly register the SqlServer connector with Kafka Connect to connect to a standalone SQL Server Instance? Note: I am NOT running SQL Server in Docker.

错误:

错误:由以下原因引起:com.microsoft.sqlserver.jdbc.SQLServerException: 到主机127.0.0.1的TCP/IP连接,端口1433失败.错误: 连接被拒绝(连接被拒绝).验证连接 特性.确保SQL Server实例在服务器上运行 主机并接受端口上的TCP/IP连接.确保TCP 防火墙不会阻止与端口的连接."

Error: Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 127.0.0.1, port 1433 has failed. Error: "Connection refused (Connection refused). Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

故障排除:

  1. 在dbo.Posts表上启用CDC(请参见下文)
  2. 验证是否已启用TCP/IP并将所有地址设置为在SQL Server配置管理器的SQL Server网络配置中的端口1433上启用并处于活动状态
  3. 禁用的Windows防火墙
  4. 在SQL Server配置管理器中启用了SQL Server浏览器
  5. 确认可以在以下位置进行telnet登录:(127.0.0.1 1433; localhost 1433; lt-ls231 1433)

上下文:

我正在尝试使用Docker在Windows 10上设置Debezium.我可以在Powershell中成功运行以下命令,而不会出现问题:

I am attempting to setup Debezium on Windows 10 using Docker. I can successfully run the following commands in Powershell without problem:

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

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

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 -e  STATUS_STORAGE_TOPIC=my_connect_statuses --link zookeeper:zookeeper --link kafka:kafka debezium/connect:1.1

当我尝试向Kafka-Connect connect注册SQL Server连接时收到错误消息(请参见上文),我运行以下命令:

I get an error (see above) when I attempt to register the SQL Server connection with Kafka-Connect connect, I run the following command:

Invoke-RestMethod -Method Post -Uri 'http://localhost:8083/connectors/' -Headers @{'Accept' = 'application/json'; 'Content-Type' = 'application/json'} -Body '{"name": "mssqlserver-localhost-testDb-connector",  "config": {"connector.class": "io.debezium.connector.sqlserver.SqlServerConnector", "database.hostname": "127.0.0.1", "database.port": "1433", "database.user": "svc_kafka", "database.password": "password", "database.dbname": "Posts", "database.server.name": "LT-LS231", "table.whitelist": "dbo.Posts", "database.history.kafka.bootstrap.servers": "kafka:9092", "database.history.kafka.topic": "dbhistory.LT-LS231" }}'

格式化的JSON如下:

The formatted JSON is as follows:

Invoke-RestMethod -Method Post -Uri 'http://localhost:8083/connectors/' -Headers @{'Accept' = 'application/json'; 'Content-Type' = 'application/json'} -Body '

{  
    "name": "mssqlserver-localhost-testDb-connector",  
    "config": {
        "connector.class": "io.debezium.connector.sqlserver.SqlServerConnector", 
        "database.hostname": "127.0.0.1", 
        "database.port": "1433", 
        "database.user": "svc_kafka", 
        "database.password": "password", 
        "database.dbname": "Posts", 
        "database.server.name": "LT-LS231", 
        "table.whitelist": "dbo.Posts", 
        "database.history.kafka.bootstrap.servers": "kafka:9092", 
        "database.history.kafka.topic": "dbhistory.LT-LS231" 
  }
}'

这是根据Debezium网站上提供的JSON建模的:

This is modeled after the JSON provided on Debezium's site: https://debezium.io/documentation/reference/1.1/connectors/sqlserver.html#sqlserver-deploying-a-connector

推荐答案

问题出在对localhost的引用中.如果在Docker容器中运行Connect,则localhost是容器的本地主机,而不是计算机的本地主机.尝试在docker0接口或所有接口上公开SQL Server,然后在注册请求中使用docker0 IP.

The problem is in the reference to the localhost. If you run the Connect in Docker container then the localhost is the localhost of the container not of the machine. Try exposing the SQL Server on docker0 interface or all intefaces and then use docker0 IP in the registration request.

这篇关于Debezium如何正确向Kafka Connect注册SqlServer连接器-连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆