首页 新闻 会员 周边 捐助

Linux MySQL数据库连接异常 ,shh连接的数据库主机账户几分钟自动断开一次

0
悬赏园豆:100 [已解决问题] 解决于 2018-01-11 16:13

自由充系统部署在10.1.3.124机器上,MySQL数据库部署在10.1.5.215机器上,最近124主机启动日志和error老是报错,隔几分钟就报一次(报错如下文),在测试的时候却能正常使用,就是启动日志老是不停的报错。而且ssh连接215主机的redis账户差不多每3分钟自动断开一次,已经把 my.cnf  设置为了60天,重启还是没用,interactive_timeout=5184000
wait_timeout=5184000。没有到主机的路由这个问题的话,ping主机的名称也ping的通,搞了好久搞不好,求大神指教

启动日志报错:

Exception in thread "Thread-431" org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.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 org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:240)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.aspire.mm.flowrecharge.domain.rechargeinter.biz.impl.ShanxiECRechargeBizImpl$$EnhancerByCGLIB$$748f184d.processShanXiECQueryGroupMemberShip(<generated>)
at com.aspire.mm.flowrecharge.system.StartupServlet$50.run(StartupServlet.java:2355)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.mysql.jdbc.exceptions.jdbc4.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 sun.reflect.GeneratedConstructorAccessor75.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1118)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2308)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:774)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
at sun.reflect.GeneratedConstructorAccessor65.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)
at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.tomcat.dbcp.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1185)
at org.apache.tomcat.dbcp.dbcp.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:79)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:202)
... 10 more
Caused by: java.net.NoRouteToHostException: 没有到主机的路由 (Host unreachable)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:244)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
... 27 more

 

error报错:

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2017-12-27 15:26:19,772 [com.aspire.mm.flowrecharge.task.GetSmsUnHandelTask]- org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.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.
2017-12-27 15:26:25,227 [com.aspire.mm.flowrecharge.domain.meberShipMessage.biz.impl.MeberShipMessageBizImpl]- 订单通知接口未通知元素添加队列MemberShipMessageQueue出错
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.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.
### The error may exist in com/aspire/mm/flowrecharge/domain/meberShipMessage/dao/impl/maps/meberShipMessageSQL.xml
### The error may involve recharge.getClientInfo
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.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 org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
at com.sun.proxy.$Proxy3.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:191)
at com.aspire.mm.flowrecharge.domain.meberShipMessage.dao.impl.MeberShipMessageDaoImpl.getClientInfo(MeberShipMessageDaoImpl.java:67)
at com.aspire.mm.flowrecharge.domain.meberShipMessage.dao.impl.MeberShipMessageDaoImpl$$FastClassByCGLIB$$44720a4a.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.aspire.mm.flowrecharge.domain.meberShipMessage.dao.impl.MeberShipMessageDaoImpl$$EnhancerByCGLIB$$aed4761a.getClientInfo(<generated>)
at com.aspire.mm.flowrecharge.domain.meberShipMessage.biz.impl.MeberShipMessageBizImpl.pushToCatch(MeberShipMessageBizImpl.java:42)
at com.aspire.mm.flowrecharge.domain.meberShipMessage.biz.impl.MeberShipMessageBizImpl$$FastClassByCGLIB$$87387d6a.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.aspire.mm.flowrecharge.domain.meberShipMessage.biz.impl.MeberShipMessageBizImpl$$EnhancerByCGLIB$$57cde13a.pushToCatch(<generated>)
at com.aspire.mm.flowrecharge.system.StartupServlet$1.run(StartupServlet.java:1149)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.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.
### The error may exist in com/aspire/mm/flowrecharge/domain/meberShipMessage/dao/impl/maps/meberShipMessageSQL.xml
### The error may involve recharge.getClientInfo
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.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 org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
... 26 more
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.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 org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:81)
at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67)
at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:279)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:72)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
... 32 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.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 sun.reflect.GeneratedConstructorAccessor75.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1118)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2308)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:774)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
at sun.reflect.GeneratedConstructorAccessor65.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)
at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.tomcat.dbcp.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1185)
at org.apache.tomcat.dbcp.dbcp.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:79)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
... 42 more
Caused by: java.net.NoRouteToHostException: 没有到主机的路由 (Host unreachable)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:244)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
... 60 more

无玄子的主页 无玄子 | 初学一级 | 园豆:114
提问于:2017-12-27 15:58
< >
分享
最佳答案
0

ssh吧~~~多半是网络不稳定啊,看这ip估计你得找网管人员吧。

收获园豆:40
花飘水流兮 | 专家六级 |园豆:13595 | 2017-12-27 16:03

不是网络不稳定哦,其他后台系统账户连接是正常的,就这个Linux账户有毛病,,防火墙应该也是正常的,不然也不可能正常工作。。。。。。

无玄子 | 园豆:114 (初学一级) | 2017-12-27 16:07

@无玄子: 你mysql背时了,ssh背时了,还正常?这台主机还有什么服务正常的 ——

如果光是一个,那么端口限制可能性较高,都两个服务这种情况了...

不知道你是不是石油还是电力还是哪家~~我给你说那帮人一天本来就没什么事,说不定就在那搞还没怎么用的机器的route table、防火墙。只要本机正常的,网络不对就不要自己去搞了,直接找网管才是正道。

花飘水流兮 | 园豆:13595 (专家六级) | 2017-12-27 16:19

 最好检测ok,留下证据,不是强去口争。

花飘水流兮 | 园豆:13595 (专家六级) | 2017-12-27 16:21

@花飘水流兮: 哥,我新手啊,不知道背时是什么鬼,我去查一下。而且那台主机我只有一个Redis账户,只知道上面的MySQL服务,不知道怎么查看其它服务是否正常啊,怎么破,求指导,现在shh连不连的上还要看运气,,,老大不知道怎么回事,让我来整,,,,我也没法了

无玄子 | 园豆:114 (初学一级) | 2017-12-27 16:34
其他回答(3)
0

减小下连接池连接idle时间看看

收获园豆:10
Daniel Cai | 园豆:10424 (专家六级) | 2017-12-27 16:05
1

有没有开启 iptables ?

收获园豆:50
dudu | 园豆:30939 (高人七级) | 2017-12-27 16:06

root@svr0000543:~# ufw status
状态:不活动

支持(0) 反对(0) 无玄子 | 园豆:114 (初学一级) | 2017-12-27 16:31

@无玄子: 是什么linux系统?是云服务器吗?

支持(0) 反对(0) dudu | 园豆:30939 (高人七级) | 2017-12-27 16:37

@dudu: 124系统是红帽,215是乌班图

支持(0) 反对(0) 无玄子 | 园豆:114 (初学一级) | 2017-12-27 16:41

@无玄子: 建议 tcpdump 抓包看看

支持(0) 反对(0) dudu | 园豆:30939 (高人七级) | 2017-12-27 16:54

@dudu: 这两天机器,啥也没操作,捉包1分钟,100多M,,,,,没看出问题

支持(0) 反对(0) 无玄子 | 园豆:114 (初学一级) | 2017-12-27 17:17

@无玄子: 可以看一下网络连接是怎么断开的

支持(1) 反对(0) dudu | 园豆:30939 (高人七级) | 2017-12-27 17:38

@dudu: 请教一下怎样有什么工具可以看得到网络是怎样断开的吗?

支持(0) 反对(0) David5201 | 园豆:534 (小虾三级) | 2017-12-28 23:00

@David5201: Wireshark 软件

支持(0) 反对(0) dudu | 园豆:30939 (高人七级) | 2017-12-29 14:23
0

个种办法都试了,间断性断开而且都可以连的话,不可能是权限问题,有可能是资源占用问题,但是资源占用不是报这个错的,检查了权限是关的,那唯有是冲突了,要么IP被抢或相同,去找了系统管理部门,果然,IP冲突,有新机台也弄了这个IP,改了IP后,没问题了

无玄子 | 园豆:114 (初学一级) | 2018-01-11 16:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册