随机连接MySQL

发布于 2024-09-03 04:23:18 字数 682 浏览 1 评论 0原文

环境:
RHEL 5 服务器、MySQL 5.1.43、PHP 5.1.6(使用 MySQLi)。
目前仅在我们的内部 VPN 网络中可用。

服务器
服务器A:网络服务器
ServerB/C/D:数据库服务器(1主2从)

错误(在ServerA上)
[Tue May 25 11:12:17 2010] [错误] [客户端 CLIENTIP] PHP 警告:mysqli::real_connect() [function.mysqli-real-connect]: (HY000/2003): 无法连接到 MySQL 服务器在 /home/****/Database.php 第 67 行的 'ServerB' (4) 上,引荐来源:[网站]

问题描述
看起来,在完全随机的时间里,我们的网站无法连接到其中一台 MySQL 服务器 - 通常是主服务器。除了上述错误消息之外,据我所知,在任何日志中都找不到任何内容,并且大多数情况下连接都是成功的,并且一切正常。只是在完全随机的时间,会弹出此错误。

没有防火墙阻止任何内部流量,超时值为 3,但不到 3 秒就无法连接。使用默认的 mysql 客户端,我可以从 ServerA 连接到 ServerB、C 和 D,但尚未遇到问题。

Environment:
RHEL 5 servers, MySQL 5.1.43, PHP 5.1.6 (using MySQLi).
Currently only available within our internal VPN network.

Servers
ServerA: Webserver
ServerB/C/D: Database server (1 master 2 slaves)

The error (on ServerA)
[Tue May 25 11:12:17 2010] [error] [client CLIENTIP] PHP Warning: mysqli::real_connect() [function.mysqli-real-connect]: (HY000/2003): Can't connect to MySQL server on 'ServerB' (4) in /home/****/Database.php on line 67, referer: [website]

Problem description
It appears that at completely random times, our website is unable to connect to one of the MySQL servers - usually the Master. Except for the forementioned error message, there is nothing to be found in any of the logs as far as I can see, and most of the times the connection is succesful and everything works as it should. It's just at completely random times, this error pops up.

There's no firewall blocking any internal traffic, timeout value is 3 but it doesn't take 3 seconds before it fails to connect. With the default mysql client I can connect from ServerA to ServerB,C and D and haven't encountered a problem yet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心头的小情儿 2024-09-10 04:23:18

libmysqlclient 中似乎存在一个错误,只有在手动设置超时值时才会注意到该错误。目前将其设置为 0 似乎可以解决该问题。有关此内容的更多信息可以在这篇文章中找到。

It appears that there's a bug in libmysqlclient that's only noticeable if you manually set a time-out value. Setting it to 0 seems to solve it, for now. More information about this can be found in this post.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文