问题描述
启用CDC功能后尝试将Debezium连接到SQL Server数据库时,出现以下错误消息:
When I'm trying to connect Debezium to my SQL Server database after enable CDC feature, I have this error message :
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" }
}'
我在这里找到了解决方法:
I found a workaround here :
https://github.com/Microsoft/mssql-jdbc/issues/879#issuecomment-438825486
但是可以将其应用于debezium连接器吗?Debezium与Sql Server 2008 R2兼容吗,因为在文档中写为:
But is it possible to apply it on debezium connector? Is Debezium compatible with Sql Server 2008 R2 because in documentation it's write :
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/kafka-debezium/连接
For information, I used Debezium Docker Images 0.9.2 :- debezium/zookeeper- debezium/kafka- debezium/connect
预先感谢您的帮助.
塞巴斯蒂安
推荐答案
我在激活TLS调试模式时发现了问题.
I found the issue when I activated TLS Debug mode.
因此,即使我在JDBC连接属性中设置了任何TLS选项,我仍然看到Java 8默认使用TLS V1.2.
So I saw that Java 8 use TLS V1.2 by default even if I set any TLS options into JDBC connection properties.
当我尝试使用Java 7连接到SQL SERVER时,它起作用了.经过一些搜索,我发现这是因为Java 7使用此TLS算法:3DES_EDE_CBC.
When I tried to connect to SQL SERVER with Java 7, it worked.After some searches I found that is because Java 7 use this TLS algorithm : 3DES_EDE_CBC.
解决方法是将 3DES_EDE_CBC
值删除到 jdk.tls.disabledAlgorithms
密钥中的java.security文件中.
The workaround is to remove the value 3DES_EDE_CBC
into java.security file in jdk.tls.disabledAlgorithms
key.
现在Debezium可以连接到我的Sql Server了!
Now Debezium can connect to my Sql Server !
别担心,我不在生产平台上工作;-)
Don't worry I'm not working with a production platform ;-)
这篇关于无法将Debezium 0.9.2连接到SQL Server 2008 R2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!