现象:html
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 60,001 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
|
『wait_timeout 过大有弊端,其体现就是 MySQL 里大量的 SLEEP 进程没法及时释放,拖累系统性能,不过也不能把这个指设置的太小,不然你可能会遭遇到“MySQL has gone away”之类的问题。』『在MySQL命令行里经过 SET来设置便可,避免服务重启:mysql> set global wait_timeout=60;』『查有无生效,用 show global variables 查全局变量:mysql> show global variables like 'wait_timeout';单纯使用 show variables 的话就等同于使用的是 show session variables,查询的是会话变量,你会误觉得设置没有生效。』
『Master failure
If the master looses connection to the database or looses the exclusive lock then it immediately shuts down. If a master shuts down or fails, one of the other slaves will grab the lock and so the topology switches to the following diagram![]()
』
『参数含义:服务器关闭非交互链接以前等待活动的秒数。在线程启动时,根据全局wait_timeout值或全局interactive_timeout值初始化会话wait_timeout值,取决于客户端类型(由mysql_real_connect()的链接选项CLIENT_INTERACTIVE定义)。
java参数默认值: 28800秒(8小时)』本文引自:http://www.cnblogs.com/zhengyun_ustc/archive/2012/11/10/activemq_wait_timeout.html