咨询关于mysql_connect超时连接
烦请各位提供思路,分析可能存在的问题
连接代码,以下简化的生产代码
$start_time = date('Y-m-d H:i:s');
if(mysql_connect($config['dbhost'], $config['dbuser'], $config['dbpw'], TRUE)){
// something code
}else{
error_log('['. date('Y-m-d H:i:s') .'] 连接失败'.$this->error().' start='.$start_time.' host='.$config['dbhost'].' user='.$config['dbuser']."\n", 3, UC_ROOT.'logs/sqlerr_'.date('Y-m-d').'.log');
}
连接超时日志,有个规律是7秒这个值
[2014-12-17 21:10:37] 连接失败Connection timed out start=2014-12-17 21:10:30 host=192.168.1.6:3306 user=cuser
[2014-12-17 21:11:15] 连接失败Connection timed out start=2014-12-17 21:11:08 host=192.168.1.6:3306 user=cuser
[2014-12-17 21:16:35] 连接失败Connection timed out start=2014-12-17 21:16:28 host=192.168.1.6:3306 user=cuser
[2014-12-17 21:34:55] 连接失败Connection timed out start=2014-12-17 21:34:48 host=192.168.1.6:3306 user=cuser
[2014-12-17 21:46:55] 连接失败Connection timed out start=2014-12-17 21:46:48 host=192.168.1.6:3306 user=cuser
[2014-12-17 21:47:24] 连接失败Connection timed out start=2014-12-17 21:47:17 host=192.168.1.6:3306 user=cuser
[2014-12-17 22:15:28] 连接失败Connection timed out start=2014-12-17 22:15:21 host=192.168.1.6:3306 user=cuser
[2014-12-17 22:38:20] 连接失败Connection timed out start=2014-12-17 22:38:13 host=192.168.1.6:3306 user=cuser
[2014-12-17 22:38:54] 连接失败Connection timed out start=2014-12-17 22:38:47 host=192.168.1.6:3306 user=cuser
[2014-12-17 22:39:41] 连接失败Connection timed out start=2014-12-17 22:39:34 host=192.168.1.6:3306 user=cuser
[2014-12-17 22:52:20] 连接失败Connection timed out start=2014-12-17 22:52:13 host=192.168.1.6:3306 user=cuser
[2014-12-17 23:21:54] 连接失败Connection timed out start=2014-12-17 23:21:47 host=192.168.1.6:3306 user=cuser
以下为部分长ping数据
PING 192.168.1.6 (192.168.1.6) 56(84) bytes of data.
64 bytes from 192.168.1.6: icmp_seq=1 ttl=64 time=0.158 ms
64 bytes from 192.168.1.6: icmp_seq=2 ttl=64 time=0.142 ms
64 bytes from 192.168.1.6: icmp_seq=3 ttl=64 time=0.153 ms
64 bytes from 192.168.1.6: icmp_seq=4 ttl=64 time=0.137 ms
64 bytes from 192.168.1.6: icmp_seq=5 ttl=64 time=0.203 ms
64 bytes from 192.168.1.6: icmp_seq=6 ttl=64 time=0.150 ms
64 bytes from 192.168.1.6: icmp_seq=7 ttl=64 time=0.139 ms
64 bytes from 192.168.1.6: icmp_seq=8 ttl=64 time=0.137 ms
64 bytes from 192.168.1.6: icmp_seq=9 ttl=64 time=0.201 ms
以下为部分php.ini部分参数设置信息
php.ini
max_execution_time = 30
max_input_time = 60
default_socket_timeout = 60
mysql.connect_timeout => 60 => 60
default_socket_timeout => 60 => 60