无法将 Debezium 0.9.2 连接到 SQL Server 2008 R2

Posted

技术标签:

【中文标题】无法将 Debezium 0.9.2 连接到 SQL Server 2008 R2【英文标题】:Can't connect Debezium 0.9.2 to a SQL Server 2008 R2 【发布时间】:2019-07-25 19:24:56 【问题描述】:

当我在启用 CDC 功能后尝试将 Debezium 连接到我的 SQL Server 数据库时,我收到以下错误消息:

java.lang.RuntimeException: Couldn't obtain database name,
    at io.debezium.connector.sqlserver.SqlServerConnection.retrieveRealDatabaseName(SqlServerConnection.java:364),
    at io.debezium.connector.sqlserver.SqlServerConnection.<init>(SqlServerConnection.java:84),
    at io.debezium.connector.sqlserver.SqlServerConnectorTask.start(SqlServerConnectorTask.java:86),
    at io.debezium.connector.common.BaseSourceTask.start(BaseSourceTask.java:47),
    at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:198),
    at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:175),
    at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:219),
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511),
    at java.util.concurrent.FutureTask.run(FutureTask.java:266),
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149),
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624),
    at java.lang.Thread.run(Thread.java:748),
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server did not return a response. The connection has been closed. ClientConnectionId:bce7b974-bac3-4068-b85f-271ba41295e4".,
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2670),
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1837),
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2257),
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921),
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762),
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077),
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:623),
    at io.debezium.jdbc.JdbcConnection.lambda$patternBasedFactory$1(JdbcConnection.java:179),
    at io.debezium.jdbc.JdbcConnection.connection(JdbcConnection.java:734),
    at io.debezium.jdbc.JdbcConnection.connection(JdbcConnection.java:729),
    at io.debezium.jdbc.JdbcConnection.queryAndMap(JdbcConnection.java:516),
    at io.debezium.jdbc.JdbcConnection.queryAndMap(JdbcConnection.java:391),
    at io.debezium.connector.sqlserver.SqlServerConnection.retrieveRealDatabaseName(SqlServerConnection.java:358),
    ... 11 more,
Caused by: java.io.IOException: SQL Server did not return a response. The connection has been closed. ClientConnectionId:bce7b974-bac3-4068-b85f-271ba41295e4,
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:780),
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:836),
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:827),
    at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:1009),
    at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:997),
    at sun.security.ssl.InputRecord.readFully(InputRecord.java:465),
    at sun.security.ssl.InputRecord.read(InputRecord.java:503),
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:975),
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367),
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395),
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379),
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1767),
    ... 22 more,

这是我的连接器配置:

curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" localhost:8083/connectors/ -d '  "name": "sql-connector",  
    "config":     
        "connector.class": "io.debezium.connector.sqlserver.SqlServerConnector",
        "database.hostname": "XXX.XXX.XXX.XXX",    
        "database.port": "1433",    
        "database.user": "login",    
        "database.password": "password",    
        "database.dbname": "BDNAME",    
        "database.server.name": "bdservername",    
        "table.whitelist": "bdSchema.TABLE",
        "database.history.kafka.bootstrap.servers": "kafka:9092",    
        "database.history.kafka.topic": "dbhistory.TABLE"  
        '

我在这里找到了解决方法:

https://github.com/Microsoft/mssql-jdbc/issues/879#issuecomment-438825486

但是可以将它应用在 debezium 连接器上吗? Debezium 是否与 Sql Server 2008 R2 兼容,因为在文档中它是这样写的:

The functionality of the connector is based upon change data capture feature provided by SQL Server Standard (since SQL Server 2016 SP1) or Enterprise edition

有关信息,我使用了 Debezium Docker Images 0.9.2: - debezium/动物园管理员 - debezium/卡夫卡 - debezium/连接

提前感谢您的帮助。

塞巴斯蒂安

【问题讨论】:

嗨,Debezium 从未在 SQL Server 2008 上测试过。我建议您尝试 authentication JDBC 连接属性中的 NotSpecified 值,因为它应该绕过 SSL 并验证 Debezium 是否工作。只有在那之后,才可能在安全层上工作。 感谢您的回复,但是如何将 authentication=NotSpecified 设置为 JDBC 连接?我尝试将 "database.authentication": "NotSpecified" 然后 "database.history.authentication": "NotSpecified" 放入连接器配置中,但结果相同 => 原因:com.microsoft.sqlserver.jdbc.SQLServerException:驱动程序无法使用安全套接字层 (SSL) 加密建立与 SQL Server 的安全连接。错误:“SQL Server 未返回响应。连接已关闭 【参考方案1】:

我在激活 TLS 调试模式时发现了问题。

所以我看到 Java 8 默认使用 TLS V1.2,即使我在 JDBC 连接属性中设置了任何 TLS 选项。

当我尝试使用 Java 7 连接到 SQL SERVER 时,它成功了。 经过一番搜索,我发现这是因为 Java 7 使用了这种 TLS 算法:3DES_EDE_CBC。

解决方法是将值 3DES_EDE_CBC 删除到 java.security 文件中的 jdk.tls.disabledAlgorithms 键中。

现在 Debezium 可以连接到我的 Sql Server 了!

别担心我没有使用生产平台;-)

【讨论】:

以上是关于无法将 Debezium 0.9.2 连接到 SQL Server 2008 R2的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Docker 中将 Debezium 连接到 MongoDB?

Debezium Kafka 连接器 mongodb:将 kafka 连接器连接到 mongodb 时出错

无法从 DataLab 连接到 Bigquery API

无法连接到 laravel 5.6 中的数据库 xampp

无法从 C# 通过 Wallet 连接到 Oracle DB

MySQL 数据库集群 - 将 SQL 节点 (mysqld) 连接到其他节点时出现问题