现象:java
程序会不定时的出现链接错误,问题bug的异常信息以下:mysql
The last packet successfully received from the server was 116 milliseconds ago. The last packet sent successfully to the server was 115 milliseconds ago.sql
java.sql.SQLException: No database selected缓存
但经过客户端sqlyog/navicat链接均为正常。bash
----------------------------------------------------------------------
ide
另:maxscale1.4.3有时还会出现挂起现象,4006端口直接关闭。后咱们用了watch命令后台跑监控。url
watch -d /bin/bash /root/sh/restart_maxsacle.sh
spa
#!/bin/bash netstat -ntlp | grep maxscale | grep 4006 > /dev/null 2>&1 if [ $? -eq 1 ];then /etc/init.d/maxscale start fi
解决:5.6如下能够直接在url上配置:autoReconnect=truerest
对于5.6以上的只能在jdbc的连接池里设置:server
第一个设置成ture,超时自动连接,对于mysql要把第二个设置成false,不启用缓存。
以上是开发须要注意的都是一些基本的配置。
其目的为:每次归还链接时执行select 'x'检测链接是否有效。