Kohana 3 和“太多连接”错误
我有一个正在生产的 Web 应用程序,它管理一个内部系统和一个网页,两者都是相关的。不仅作为 CMS+Web,两者的工作方式都类似于用户控制系统、请求管理、CMS 和 Web。两个系统都有太多用户(管理员、编辑者和最终用户)。系统采用MySQL作为数据库引擎。
所以,你现在处于上下文中。
我有以下 SQL 错误;
Database_Exception [ 0 ]: [1040] Too many connections ~ MODPATH/database/classes/kohana/database/mysql.php [ 67 ]
查看服务器端,确实如此,服务器与数据库引擎的连接太多。消息是对的。
该网站已关闭。我重新启动 Apache,一切正常。 但显然这会发生。
我正在谷歌搜索并阅读 MySQL 手册,发现存在一个增加连接数的配置(从默认值 151 到另一个值)。 但是,我正在阅读有关 Kohana 配置的信息,并且我读到存在一个查询缓存系统(进入数据库配置文件)。所以,我不知道缓存是否将查询结果“保存”在内存中,或者缓存“保存”查询本身以防止 Query_Builder 或 ORM 过载,因此,如果查询之前已生成,则不要重新生成生成它并仅执行它。
我需要一个解决方案,但要避免(尽可能)MySQL 配置修改。
谢谢!
I have a web application in production that manages an internal system and a web page, both in relation. Not only as a CMS+Web, both works like a user-control-system, requests-management, CMS and web. Both systems have too many users (admins, editors and final-users). The system uses MySQL as DB engine.
So, you are in context now.
I had the following SQL error;
Database_Exception [ 0 ]: [1040] Too many connections ~ MODPATH/database/classes/kohana/database/mysql.php [ 67 ]
Looking at the server side, it's real, the server had too many connections to the DB Engine. The message is right.
The website was down. I restart Apache and everything works fine.
But obviously this would ever happen.
I'm googling and reading the MySQL manual and see that exists a configuration to increase the connections number (from 151, the default, to another value).
But, I'm reading about the Kohana config and I read that exists a queries caché system (into the database configuration file). So, I don't know if that cache "saves" in memory the query result or it the cache "saves" the query itself to prevent the overload of Query_Builder or ORM, so if the query had been previously generated don't re-generate it and only execute it.
I need a solution but avoiding (as possible as it could be) the MySQL config modification.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 mysql 配置文件
my.ini
中max_connections
的设置。默认设置为 100,您可以将其更改为 300 或更多。然后,使用命令
netstat -np
查看哪些进程连接到mysql,并杀死未知的进程。完成所有更改后,重新启动 mysql 守护进程:
如果这没有帮助,请阅读: http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html
并且不要忘记对所有 mysql 数据库进行转储。
Check your setting of
max_connections
in the mysql config filemy.ini
. The default setting is 100, you may change it to 300 or more.Then, look what processes are connected to mysql with the command
netstat -np
, and kill unknown ones.After all changes restart you mysql daemon:
If this doesn't help, read: http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html
And do not forget make dumps for all mysql dbs.