douhui1630 2010-05-26 08:46
浏览 25
已采纳

随机连接MySQL

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.

  • 写回答

1条回答 默认 最新

  • doutui839638 2010-05-31 11:07
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度