com.mysql.cj.jdbc.exceptions.communicationsexception:通信链路故障2021

gzszwxb4  于 2021-07-12  发布在  Java
关注(0)|答案(1)|浏览(532)

我有一个使用tomcat和mysql的生产服务器。今天所有的网站,都停止连接到各自的数据库。
重新启动tomcat时,显示无法为所有网站/数据库创建连接池。以下是错误日志(对于一个网站):

23-Apr-2021 12:18:49.438 INFO [evaluaciones-grupocomidas.com-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor [/opt/tomcat/conf/Catalina/evaluaciones-grupocomidas.com/ROOT.xml]
23-Apr-2021 12:18:49.690 SEVERE [evaluaciones-grupocomidas.com-startStop-1] org.apache.tomcat.jdbc.pool.ConnectionPool.init Unable to create initial connections of pool.
        com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
                at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
                at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
                at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
                at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
                at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
                at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
                at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:319)
                at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:212)
                at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:736)
                at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:668)
                at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:483)
                at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
                at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118)
                at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107)
                at org.apache.tomcat.jdbc.pool.DataSourceFactory.createDataSource(DataSourceFactory.java:560)
                at org.apache.tomcat.jdbc.pool.DataSourceFactory.getObjectInstance(DataSourceFactory.java:244)
                at org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:94)
                at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:332)
                at org.apache.naming.NamingContext.lookup(NamingContext.java:839)
                at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
                at org.apache.naming.NamingContext.lookup(NamingContext.java:827)
                at org.apache.naming.NamingContext.lookup(NamingContext.java:173)
                at org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1017)
                at org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:557)
                at org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:253)
                at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
                at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5063)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
                at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
                at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
                at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
                at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:614)
                at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1823)
                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.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

root.xml的内容是:

<Resource
            name="jdbc/rhwebDB"
            auth="Container"
            type="javax.sql.DataSource"
            factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
            testWhileIdle="true"
            testOnBorrow="true"
            testOnReturn="false"
            validationQuery="SELECT 1"
            validationInterval="30000"
            timeBetweenEvictionRunsMillis="30000"
            maxActive="5"
            minIdle="0"
            maxIdle="5"
            maxWait="10000"
            initialSize="2"
            removeAbandonedTimeout="60"
            removeAbandoned="true"
            logAbandoned="true"
            minEvictableIdleTimeMillis="30000"
            username="grupocom_rhuser"
            password="mypwd"
            driverClassName="com.mysql.cj.jdbc.Driver"
            url="jdbc:mysql://127.0.0.1:3306/grupocom_rhweb?serverTimezone=EST5EDT"/>

这个问题从今天开始,我已经没有选择了。它在数月(或数年)内运行良好。
jdbc驱动程序是:mysql-connector-java-8.0.16.jar(它位于%catalina\u home%/lib/mysql版本是:5.7.34)
我已经尝试过从url参数中删除“servertimezone”,使用服务器的ip而不是127.0.0.1以及其他一些东西,但是仍然不起作用。
任何帮助都将不胜感激
更新
我在另一个日志文件中发现了例外的其余部分,可能与此相关:

Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
            at sun.security.ssl.HandshakeContext.<init>(HandshakeContext.java:171)
            at sun.security.ssl.ClientHandshakeContext.<init>(ClientHandshakeContext.java:98)
            at sun.security.ssl.TransportContext.kickstart(TransportContext.java:220)
            at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:428)
            at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:316)
            at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:188)
            at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99)
            at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:352)
wz8daaqr

wz8daaqr1#

我能够解决这个问题,按照其他帖子的建议:
我在java.security文件中注解/禁用了以下行:


# jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, \

# DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \

# include jdk.disabled.namedCurves

在我的例子中,java.security文件位于:
./usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7\u 9.x86\u 64/jre/lib/security/

相关问题