datax连不上mysql

2021.08.10.数据平台团队利用datax抽取mysql到hdfs一直报错,如下是整个过程,仅供参考。


[TOC]

报错信息

2021.08.10.输出datax报错

12-08-2021 16:29:03 CST xxx_fb_u_purchasein__20210812 INFO - 2021-08-12 16:29:03.574 [main] INFO  JobContainer - DataX jobContainer starts job.
12-08-2021 16:29:03 CST xxx_fb_u_purchasein__20210812 INFO - 2021-08-12 16:29:03.575 [main] INFO  JobContainer - Set jobId = 0
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO - 2021-08-12 16:29:05.404 [job-0] WARN  DBUtil - test connection of [jdbc:mysql://x.x.x.x:3306/xxx?characterEncoding=utf-8] failed, for Code:[MYSQLErrCode-02], Description:[数据库服务的IP地址或者Port错误,请检查填写的IP地址和Port或者联系DBA确认IP地址和Port是否正确。如果是同步中心用户请联系DBA确认idb上录入的IP和PORT信息和数据库的当前实际信息是一致的].  -  具体错误信息为:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO - 
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO - The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server..
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO - 2021-08-12 16:29:05.429 [job-0] ERROR RetryUtil - Exception when calling callable, 异常Msg:DataX无法连接对应的数据库,可能原因是:1) 配置的ip/port/database/jdbc错误,无法连接。2) 配置的username/password错误,鉴权失败。请和DBA确认该数据库的连接信息是否正确。
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO - java.lang.Exception: DataX无法连接对应的数据库,可能原因是:1) 配置的ip/port/database/jdbc错误,无法连接。2) 配置的username/password错误,鉴权失败。请和DBA确认该数据库的连接信息是否正确。
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.plugin.rdbms.util.DBUtil$2.call(DBUtil.java:71) ~[plugin-rdbms-util-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.plugin.rdbms.util.DBUtil$2.call(DBUtil.java:51) ~[plugin-rdbms-util-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.common.util.RetryUtil$Retry.call(RetryUtil.java:164) ~[datax-common-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.common.util.RetryUtil$Retry.doRetry(RetryUtil.java:111) ~[datax-common-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.common.util.RetryUtil.executeWithRetry(RetryUtil.java:30) [datax-common-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.plugin.rdbms.util.DBUtil.chooseJdbcUrl(DBUtil.java:51) [plugin-rdbms-util-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.plugin.rdbms.reader.util.OriginalConfPretreatmentUtil.dealJdbcAndTable(OriginalConfPretreatmentUtil.java:92) [plugin-rdbms-util-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.plugin.rdbms.reader.util.OriginalConfPretreatmentUtil.simplifyConf(OriginalConfPretreatmentUtil.java:59) [plugin-rdbms-util-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.plugin.rdbms.reader.util.OriginalConfPretreatmentUtil.doPretreatment(OriginalConfPretreatmentUtil.java:33) [plugin-rdbms-util-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.plugin.rdbms.reader.CommonRdbmsReader$Job.init(CommonRdbmsReader.java:55) [plugin-rdbms-util-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.plugin.reader.mysqlreader.MysqlReader$Job.init(MysqlReader.java:37) [mysqlreader-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.core.job.JobContainer.initJobReader(JobContainer.java:673) [datax-core-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.core.job.JobContainer.init(JobContainer.java:303) [datax-core-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.core.job.JobContainer.start(JobContainer.java:113) [datax-core-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.core.Engine.start(Engine.java:92) [datax-core-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.core.Engine.entry(Engine.java:171) [datax-core-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:05 CST xxx_fb_u_purchasein__20210812 INFO -     at com.alibaba.datax.core.Engine.main(Engine.java:204) [datax-core-0.0.1-SNAPSHOT.jar:na]
12-08-2021 16:29:06 CST xxx_fb_u_purchasein__20210812 INFO - 2021-08-12 16:29:06.446 [job-0] ERROR RetryUtil - Exception when calling callable, 即将尝试执行第1次重试.本次重试计划等待[1000]ms,实际等待[1003]ms, 异常Msg:[DataX无法连接对应的数据库,可能原因是:1) 配置的ip/port/database/jdbc错误,无法连接。2) 配置的username/password错误,鉴权失败。请和DBA确认该数据库的连接信息是否正确。]
12-08-2021 16:29:06 CST xxx_fb_u_purchasein__20210812 INFO - 2021-08-12 16:29:06.479 [job-0] WARN  DBUtil - test connection of [jdbc:mysql://x.x.x.x:3306/xxx?characterEncoding=utf-8] failed, for Code:[MYSQLErrCode-02], Description:[数据库服务的IP地址或者Port错误,请检查填写的IP地址和Port或者联系DBA确认IP地址和Port是否正确。如果是同步中心用户请联系DBA确认idb上录入的IP和PORT信息和数据库的当前实际信息是一致的].  -  具体错误信息为:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
12-08-2021 16:29:06 CST xxx_fb_u_purchasein__20210812 INFO - 
12-08-2021 16:29:06 CST xxx_fb_u_purchasein__20210812 INFO - The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server..
12-08-2021 16:29:08 CST xxx_fb_u_purchasein__20210812 INFO - 2021-08-12 16:29:08.480 [job-0] ERROR RetryUtil - Exception when calling callable, 即将尝试执行第2次重试.本次重试计划等待[2000]ms,实际等待[2000]ms, 异常Msg:[DataX无法连接对应的数据库,可能原因是:1) 配置的ip/port/database/jdbc错误,无法连接。2) 配置的username/password错误,鉴权失败。请和DBA确认该数据库的连接信息是否正确。]
12-08-2021 16:29:08 CST xxx_fb_u_purchasein__20210812 INFO - 2021-08-12 16:29:08.518 [job-0] WARN  DBUtil - test connection of [jdbc:mysql://x.x.x.x:3306/xxx?characterEncoding=utf-8] failed, for Code:[MYSQLErrCode-02], Description:[数据库服务的IP地址或者Port错误,请检查填写的IP地址和Port或者联系DBA确认IP地址和Port是否正确。如果是同步中心用户请联系DBA确认idb上录入的IP和PORT信息和数据库的当前实际信息是一致的].  -  具体错误信息为:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
12-08-2021 16:29:08 CST xxx_fb_u_purchasein__20210812 INFO -

2021.08.13.输出底层堆栈报错

INFO - Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

处理过程

2021.08.12.尝试调整mysql参数无效

show variables where variable_name in ('connect_timeout','net_read_timeout'); 
set global connect_timeout=60;    #.从10改为60
set global net_read_timeout=60;   #.从30改为60

2021.08.12.尝试修改nginx参数无效

注:mysql内网,前面使用了nginx代理

worker_processes 4;         #.新增参数
worker_connections 10240;   #.从1024改为10240

解决方案

1.修改java.security去掉SSLv3协议

去datax所在服务器,找到jdk/jre/lib/security/java.security文件,去掉SSLv3

find / -name java.security
cat /home/data/package/jdk1.8.0_261/jre/lib/security/java.security | grep jdk.tls.disabledAlgorithms

#找到:jdk.tls.disabledAlgorithms=SSLv3, RC4, DES, MD5withRSA, DH keySize < 1024, \

2.升级JDK版本

若上面无效,请尝试将 openjdk version从 1.8.0_292 换到 1.8.0_261(2021.08.13.验证有效

[root@localhost]# java -version
java version "1.8.0_261"

续 Caused by: java.io.EOFException: Can not read response from server

  • 2021.11.23.王国超反馈:抽取x.x.4.53:3306上面的xxx-asset-auth-sit库,第一次获取元数据成功,第二连接数据库出现异常,错误日志如下:
23-11-2021 10:30:24 CST dwh-dataimport INFO - Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
23-11-2021 10:30:24 CST dwh-dataimport INFO - The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
23-11-2021 10:30:24 CST dwh-dataimport INFO - Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
  • 尝试调整mysql参数
show variables where variable_name in ('connect_timeout','net_read_timeout'); 
set global connect_timeout=60;    #.从10改为60
set global net_read_timeout=60;   #.从30改为60
Copyright © www.sqlfans.cn 2024 All Right Reserved更新时间: 2022-11-11 22:29:30

results matching ""

    No results matching ""