随机“无法连接到‘IP’上的 MySQL 服务器 (4)”

随机“无法连接到‘IP’上的 MySQL 服务器 (4)”

我有一台服务器(服务器 A),它每 30 秒向另一台服务器(服务器 B)执行一次 SQL 查询(它们都是我拥有的专用服务器)。但服务器 A 会随机(并非 100% 的时间)获取:

[2003]: Can't connect to MySQL server on 'x.x.x.x' (4)

或者

[2003]: Can't connect to MySQL server on 'x.x.x.x' (101)

示例日志文件:

08/02/2019 - 04:37:17: Rows returned: 405
08/02/2019 - 04:37:47: Rows returned: 405
08/02/2019 - 04:38:17: Rows returned: 405
08/02/2019 - 04:38:47: Rows returned: 405
08/02/2019 - 04:39:17: Rows returned: 405
08/02/2019 - 04:39:47: Rows returned: 405
08/02/2019 - 04:40:17: Rows returned: 405
08/02/2019 - 04:40:47: Rows returned: 405
08/02/2019 - 04:41:17: Rows returned: 405
08/02/2019 - 04:41:47: Rows returned: 405
08/02/2019 - 04:42:17: Rows returned: 405
08/02/2019 - 04:42:47: Rows returned: 405
08/02/2019 - 04:43:17: Rows returned: 405
08/02/2019 - 04:43:46: Rows returned: 405
08/02/2019 - 04:44:18: Rows returned: 405
08/02/2019 - 04:44:48: Rows returned: 405
08/02/2019 - 04:45:18: Rows returned: 405
08/02/2019 - 04:45:48: Rows returned: 405
08/02/2019 - 04:46:27: [2003]: Can't connect to MySQL server on 'x.x.x.x' (4)
08/02/2019 - 04:46:49: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:47:27: [2003]: Can't connect to MySQL server on 'x.x.x.x' (4)
08/02/2019 - 04:47:57: [2003]: Can't connect to MySQL server on 'x.x.x.x' (4)
08/02/2019 - 04:48:17: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:48:47: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:49:17: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:49:47: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:50:17: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:50:47: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:51:17: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:51:47: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:52:17: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:52:48: Rows returned: 405
08/02/2019 - 04:53:18: Rows returned: 405
08/02/2019 - 04:53:48: Rows returned: 405
08/02/2019 - 04:54:18: Rows returned: 405
08/02/2019 - 04:54:48: Rows returned: 405
08/02/2019 - 04:55:18: Rows returned: 405
08/02/2019 - 04:55:48: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:56:17: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:56:47: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:57:18: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:57:47: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:58:17: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:58:47: [2003]: Can't connect to MySQL server on 'x.x.x.x' (101)
08/02/2019 - 04:59:18: Rows returned: 405
08/02/2019 - 04:59:48: Rows returned: 405
08/02/2019 - 05:00:18: Rows returned: 405
08/02/2019 - 05:00:48: Rows returned: 405
08/02/2019 - 05:01:18: Rows returned: 405

...

08/02/2019 - 22:07:57: Rows returned: 410
08/02/2019 - 22:08:27: Rows returned: 410
08/02/2019 - 22:08:58: Rows returned: 410
08/02/2019 - 22:09:39: [2013]: Lost connection to MySQL server during query
08/02/2019 - 22:10:06: [2003]: Can't connect to MySQL server on 'x.x.x.x' (4)
08/02/2019 - 22:10:27: Rows returned: 410
08/02/2019 - 22:10:57: Rows returned: 410
08/02/2019 - 22:11:27: Rows returned: 410

其中 xxxx 是服务器 B 的 IP。

服务器 B 没有任何防火墙规则,并且 MySQL 服务器一直在运行,因为我可以从我的电脑上的工作台连接,并且可以连接到运行 PHP + MySQL 的网站。

我使用另一台服务器(服务器 C)测试连接到服务器 B,但问题仍然存在,所以我认为问题出在服务器 B,但我不知道该怎么做。

奇怪的想法是,我同时运行服务器 A 和服务器 C,有时服务器 A 出现这个问题,而服务器 C 运行正常,反之亦然。

谢谢。

答案1

看起来像是网络问题。这些服务器位于 LAN 中还是位于不同的区域/位置?如何建立连接?是通过公共 WAN 接口还是 VPN?此外,当您的脚本执行时,您是否可以尝试在所有服务器之间运行连续 ping 以查看是否有任何数据包丢失?可能有很多原因。

维卡

相关内容