驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接;
这是最近使用jdbc连接sqlserver和 debzium监控sqlserver同时都遇到的问题
jdbc解决方案:
加上 ;trustServerCertificate=true;encrypt=false即可
String url = "jdbc:sqlserver://" + ip + ":" + port + ";databaseName=" + dbName +
";trustServerCertificate=true;encrypt=false";
debzium解决方案;
配置中加上:
.with("database.encrypt", false)
去掉加密
io.debezium.config.Configuration configuration = io.debezium.config.Configuration.create()
//连接器的Java类名称
.with("connector.class", "io.debezium.connector.sqlserver.SqlServerConnector")
//偏移量持久化,用来容错 默认值
.with("offset.storage", "org.apache.kafka.connect.storage.FileOffsetBackingStore")
//偏移量持久化文件路径 默认/tmp/offsets.dat 如果路径配置不正确可能导致无法存储偏移量 可能会导致重复消费变更
//如果连接器重新启动,它将使用最后记录的偏移量来知道它应该恢复读取源信息中的哪个位置。
.with("offset.storage.file.filename", offsetStorageFileFilename)
//捕获偏移量的周期
.with("offset.flush.interval.ms", "6000")
//连接器的唯一名称
.with("name", source.getDbName() + CdcConstant.point + source.getId())
//为此连接器创建的最大任务数
.with("tasks.max", "1")
//为连接器捕获更改的 数据库服务器标识并提供命名空间的逻辑名称
.with("database.server.name", "sqlserver_server" + CdcConstant.point + source.getId())
//.with("database.server.id", source.getId())
.with("database.hostname", source.getDbIp())
.with("database.port", source.getDbPort())
// 用户的名称,在为连接器创建用户中指定
.with("database.user", source.getDbUser())
// 用户的密码,在为连接器创建用户中指定
.with("database.password", source.getDbPassword())
//要从中捕获更改的数据库的名称
.with("database.dbname", source.getDbName())
.with("plugin.name", "sqlserveroutput")
//需要捕获的表
.with("table.include.list", tableJoiner.toString())
//历史变更记录
.with("database.history", "io.debezium.relational.history.FileDatabaseHistory")
//历史变更记录存储位置
.with("database.history.file.filename", databaseHistoryFileFilename)
//解决捕获数据的延迟过大问题
.with("log.mining.strategy", "online_catalog")
.with("decimal.handling.mode", "string")
.with("database.encrypt", false)
.build();