我正在用WordPress建立一个网站,在这一周内,它开始崩溃,并显示了Error establishing a database connection消息。我创建了一个只连接到数据库的测试归档,它告诉我错误是“连接太多”。
我非常确定我是唯一一个访问这个网站的人(我还在开发它,apache的日志没有显示更多的访问量),我认为Dropbox的WordPress备份插件是唯一一个可以经常使用数据库的插件,但我仍然不认为我应该看到这个错误。
"show processlist“的输出只显示了"show processlist”查询。
"show status like '%con'“的输出如下:
+----------------------------------------+--------+
| Variable_name | Value |
+----------------------------------------+--------+
| Aborted_connects | 41002 |
| Com_show_contributors | 0 |
| Connections | 337541 |
| Max_used_connections | 152 |
| Performance_schema_cond_classes_lost | 0 |
| Performance_schema_cond_instances_lost | 0 |
| Ssl_client_connects | 0 |
| Ssl_connect_renegotiates | 0 |
| Ssl_finished_connects | 0 |
| Threads_connected | 151 |
+----------------------------------------+--------+连接的线程似乎总是最多
我能做什么?这是服务器问题吗?
编辑:正如@JakeGould建议我运行MySQL调优入门脚本,但它死于连接太多错误,输出如下所示:
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 5.5.36-cll x86_64
Uptime = 0 days 0 hrs 56 min 33 sec
Avg. qps = 59
Total Questions = 200437
Threads Connected = 151
Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations
To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service
SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 10.000000 sec.
You have 4127 out of 200644 that take longer than 10.000000 sec. to complete
Your long_query_time seems to be fine
BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/5.5/en/point-in-time-recovery.html
WORKER THREADS
Current thread_cache_size = 0
Current threads_cached = 0
Current threads_per_sec = 4
Historic threads_per_sec = 2
Threads created per/sec are overrunning threads cached
You should raise thread_cache_size
MAX CONNECTIONS
Current max_connections = 151
Current threads_connected = 150
Historic max_used_connections = 152
The number of used connections is 100% of the configured maximum.
You should raise max_connections
INNODB STATUS
Current InnoDB index space = 448 K
Current InnoDB data space = 3 M
Current InnoDB buffer pool free = 82 %
Current innodb_buffer_pool_size = 128 M
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory
ERROR 1040 (08004): Too many connections发布于 2014-04-20 03:34:29
我以前也有过这样的经历。有可能有许多站点使用pconnect共享相同的服务器/数据库。特别是在共享主机解决方案中,最好使用标准连接。因此,改为使用mysql_connect()而不是mysql_pconnect()。
发布于 2014-04-20 06:32:09
这是专用服务器吗?还是共享主机?或者甚至是共享DB池?
虽然我的直觉告诉我这不是一个简单的性能调优问题,但我仍然建议您使用MySQL Tuning Primer Script located here来查看它是否揭示了您的设置的任何奇怪之处。非常容易使用&推荐非常准确。
根据您的设置,您可能需要学习如何手动调整性能-这意味着您需要自己学习解释MySQL输出并执行它-但是这个脚本在我使用过的95%的设置中都工作得很好。另外5%是数据库特有的设置,需要更多的自定义维护。我强烈推荐像this one on the MySQL performance blog这样的教程。
此外,还特别介绍了在连接到WordPress中的数据库时可以采取哪些措施来解决问题。
https://stackoverflow.com/questions/23174514
复制相似问题