mysql client常见error总结

mysql 客户端连接服务器,客户端报对应的错误号总结:

 1.      Error  104

mysql@longxibendi-dba-u-abcd00.longxibendi:~$perror 104

OS error code 104:  Connection reset by peer

这个是由于server端 backlog 满了 导致。

 2.  Error 110

mysql@longxibendi-dba-u-abcd00.longxibendi:~$perror 110

OS error code 110:  Connection timed out

这个是与server端 连接时 超时 导致。超时时间超过了客户端time out。

 3. Error 111

mysql@longxibendi-dba-u-abcd00.longxibendi:~$perror 111

OS error code 111:  Connection refused

这个是与server端 连接,被server连接拒绝,说明这个端口不处于监听状态,或该端口不开放导致。

 4. Error 4

mysql@longxibendi-dba-u-abcd00.longxibendi:~$perror 4

OS errorcode   4:  Interrupted system call

这个说明,客户端发起第一个tcp包(syn包),在客户端设置的时间内,没有得到响应。在没有超过客户端的timeout时间(也有其它原因,比如文件句柄不够也会被OS断开这次连接),客户端被OS断开了。

 重点说明下 error 4

mysql@longxibendi-dba-u-abcd00.longxibendi:~$mysql -hlongxibendi-cd-pa-abcd00  -P3309 --connect-time=5

ERROR 2003 (HY000): Can't connect to MySQL server on'longxibendi-cd-pa-abcd00' (4)

mysql@longxibendi-dba-u-abcd00.longxibendi:~$time mysql -hlongxibendi-cd-pa-abcd00  -P3306 --connect-time=8

ERROR 2003 (HY000): Can't connect to MySQL server on'longxibendi-cd-pa-abcd00' (4)

real    0m8.006s

user    0m0.004s

sys     0m0.001s

mysql@longxibendi-dba-u-abcd00.longxibendi:~$mysql -hlongxibendi-cd-pa-abcd00 -P3309 --connect-time=10

ERROR 2013 (HY000): Lost connection to MySQL server at 'readinginitial communication packet', system error: 110

 客户端与server进行连接,连接重试次数,取决于/proc/sys/net/ipv4/tcp_syn_retries 这个参数(测试的服务器,该参数=1)

这样,客户端,第一次发起连接,持续3s,不成功,进行第一次重试,持续6s,如果不成功,则被OS断开。

 所以,在设置为 connect-time=5、8s 的二次测试中,都是因为,第一次重试,重试还没完成,但超过connect-time时间,客户端被OS断开。(因为要完成第一次重试,至少需要9s,而connect-time小于9s)。故而报 error 4 。

       在设置为connect-time=10s的测试中,客户端第一次发起连接,持续3s,不成功,进行第一次重试,重试完,还没成功,到达connect-time时间,客户端断开。故而报 error 110 。

 总结下,假设 /proc/sys/net/ipv4/tcp_syn_retries的值为 n

 则,在 tcp发起连接时,先发送syn包,在没有超过 connect-time 之前,依次重试时间间隔规律为

3s    6s     12s   24s     48s

0次    第1次   第2次  第3次   第4次    

 第0次,发syn包,持续3s等响应,如果没有,重试第1次,发送syn包,持续6s,如果没有重试第2次,发syn包,持续12s,依次类推

总花费时间为:

传输时间+间隔时间=传输时间  + 3*[1*(1-2n)/(1-2) + 2 n]=3 (2n+1 -  1 ) + 传输时间

因为传输时间基本为0s

所以省略传输时间,总花费时间大概为 3 (2n+1  -  1 ) 秒

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值