Seatunnel无法连接低版本的SQLServer

5/3/2025 SeatunnelSQLServer

通过Docker部署了Seatunnel服务,连接SQLServer的时候出现错误,这里是因为新版Java会禁止TLS 1.0 and 1.1,所以需要自己重新打包一下镜像。

com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to sql server by using Secure Sockets Layer (SSL). Error:The server selected protocol version TLS10 is not accepted by client preferences [TLS12]”。 ClientConnectionId:7488157a-7d71-4424-b37e-3061e31729d9
1

如果直接根据源码构建的话,会导致connectors以及lib都是空的,需要设置挂载,所以最好是在构建镜像的时候直接打包进去。

首先先拉一下最新的Seatunnel镜像docker pull apache/seatunnel:2.3.10然后启动,之后从容器内将connectors以及lib都copy出来。

之后创建一个文件夹需要包含以下内容:

- apache-seatunnel-2.3.10-bin.tar.gz
- connectors
- Dockerfile
- lib
1
2
3
4

源码是这样下载:

export version="2.3.10"
wget "https://archive.apache.org/dist/seatunnel/${version}/apache-seatunnel-${version}-bin.tar.gz"
1
2

Dockerfile是这样的,最好将源码下到本地然后COPY进去,不然下载可能会非常慢。

FROM openjdk:8
ARG VERSION=2.3.10
# Build from Source Code And Copy it into image
COPY ./apache-seatunnel-${VERSION}-bin.tar.gz /opt/
# Download From Internet
# Please Note this file only include fake/console connector, You'll need to download the other connectors manually
# wget -P /opt https://dlcdn.apache.org/seatunnel/${VERSION}/apache-seatunnel-${VERSION}-bin.tar.gz
RUN cd /opt && \
    tar -zxvf apache-seatunnel-${VERSION}-bin.tar.gz && \
    mv apache-seatunnel-${VERSION} seatunnel && \
    rm apache-seatunnel-${VERSION}-bin.tar.gz && \
    sed -i 's/#rootLogger.appenderRef.consoleStdout.ref/rootLogger.appenderRef.consoleStdout.ref/' seatunnel/config/log4j2.properties && \
    sed -i 's/#rootLogger.appenderRef.consoleStderr.ref/rootLogger.appenderRef.consoleStderr.ref/' seatunnel/config/log4j2.properties && \
    sed -i 's/rootLogger.appenderRef.file.ref/#rootLogger.appenderRef.file.ref/' seatunnel/config/log4j2.properties && \    
    cp seatunnel/config/hazelcast-master.yaml seatunnel/config/hazelcast-worker.yaml && \
    # Enable TLS 1.0 and 1.1 by modifying java.security
    sed -i 's/jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1/jdk.tls.disabledAlgorithms=SSLv3/' $JAVA_HOME/jre/lib/security/java.security
WORKDIR /opt/seatunnel
COPY ./connectors /opt/seatunnel/connectors
COPY ./lib /opt/seatunnel/lib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

之后build然后启动即可,再次测试SQLServer的任务就可以成功连接了。