MySql *完全随机* 无法连接到任何指定的 MySQL 主机
这简直要了我的命。我们有一个基于 MySQL 数据库的 ASP.NET/Mono 应用程序。几个月来,我们一直被完全随机但持续出现的“无法连接到任何指定的 MySQL 主机”所困扰。我绝不是 MySQL 专业人士,我希望这只是一些愚蠢的事情。
详细信息:
MySQL 5.5.17
MySQL 连接器/Net 6.4.4
单声道 2.10.8
MonoDevelop 2.8.6.5
连接字符串:SERVER=localhost,3306;DATABASE=xxx;UID=xxx;PWD=xxx;CONNECTION TIMEOUT=90;Encrypt=false;
Max_connections 设置为 150。连接永远不会超过 5 个,并且它们都是活动的(可能是由于池化)。
该应用程序是 C# ASP.NET 3.5。在 Windows/IIS 上稳定运行多年。九个月前,我们的市场引导我们放弃 Windows,因此我们(我可以简单地补充一下)将整个系统迁移到 Mono/Apache。
此问题仅发生在 Mono 端,但这很重要,因为我们已经终止了 Windows 支持。
平均每小时发生约 10 次,但间隔变化很大。
以下配置中已出现此问题:
Ubuntu 11/Apache2/mod_mono
OSX Lion/Apacke2/mod_mono
Ubuntu 11/xsp2/MonoDevelop 调试服务器
OSX Lion/xsp2/MonoDevelop 调试服务器
搞乱了 keepalive、wait_timeout、connectionreset 等,但无济于事。时间似乎没有任何影响。该错误是在 conn.open 上瞬时发生的 - 不是在任何连接超时之后。
这里有一个线索 - 应用程序绝对不会在 Pooling=false 的情况下运行。几乎每次连接尝试都会失败。当然,我希望启用池化,但我不确定为什么没有池化就无法工作。
应用程序有一个内置的“心跳”(数据库中的用户会话) - 每 2 分钟一次。
最令人抓狂的是什么?它绝对不能在运行环境中按需再现——它是随机的。我已经检查了查询大小、执行时间等。
在一个场景中我可以实现它:在 Ubuntu 服务器或 OSX 初始启动时,Mono 第一次连接到 MySQL - 它会发生然后。之后,大家都在猜测。
This one is killing me. We have an ASP.NET/Mono application on a MySQL database. For months we've been plagued by a completely random but consistent occurrence of "Unable to connect to any of the specified MySQL hosts". I'm by no means a MySQL pro, and I hope this is something silly.
Specifics:
MySQL 5.5.17
MySQL Connector/Net 6.4.4
Mono 2.10.8
MonoDevelop 2.8.6.5
Connection string: SERVER=localhost,3306;DATABASE=xxx;UID=xxx;PWD=xxx;CONNECTION TIMEOUT=90;Encrypt=false;
Max_connections is set to 150. There are never more than 5 connections, and they are all active (probably due to the pooling).
The application is C# ASP.NET 3.5. Runs solid as a rock for years on Windows/IIS. Nine months ago our market led us to get off Windows, so we (easily I might add) moved the whole thing to Mono/Apache.
The issue only occurs on the Mono side, but that's critical since we've retired our Windows support.
Happens on average about 10 times an hour, but spacing varies wildly.
The issue has been witnessed in the following configurations:
Ubuntu 11/Apache2/mod_mono
OSX Lion/Apacke2/mod_mono
Ubuntu 11/xsp2/MonoDevelop debug server
OSX Lion/xsp2/MonoDevelop debug server
Have messed with keepalive, wait_timeout, connectionreset, etc to no avail. Timings seem to have no effect. The error is instantaneous on conn.open - not after any connection timeout.
Here's a clue - the app absolutely will not run with Pooling=false. Nearly every connection attempt fails. Of course I want pooling on, but I'm not sure why it wouldn't work without.
The application has a built in "heartbeat" (user's session in the database) - every 2 minutes.
The most maddening of all? It absolutely cannot be reproduced on demand in a running environment - it's random. I've examined query sizes, execution times, etc.
In exactly one scenario can I make it happen: On initial startup of an Ubuntu server or OSX, the very first time Mono makes it's first connection to MySQL - it will happen then. After that, it's anybody's guess.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,这已经很旧了,但是我在这上面浪费了很多时间,我必须分享我终于找到的这篇救生文章:让 Mono 和 Mysql 协同工作
我总结了链接最终的情况404 someday :必须定义连接字符串的每个变量。所以,是的,这包括端口,我以前从未在连接字符串中定义过它。
对我来说它解决了问题。
Ok, this is old, but i lost so much time on this, i've to share this life saving article i finally found : Getting Mono and Mysql to play nice together
And i sum up for the case the link end up in 404 someday : EVERY variable of the connection string MUST be defined. So, yes, that includes port, which i never had to define in a connection string ever in my life before.
For me it solved the problem.