《MYSQL教程CentOS 7中MySQL連接數被限制為214個的解決方法》要點:
本文介紹了MYSQL教程CentOS 7中MySQL連接數被限制為214個的解決方法,希望對您有用。如果有疑問,可以聯系我們。
MYSQL應用發現問題
MYSQL應用最近在項目中遇到一個問題,由于連接數過多,提示 “Too many connections” ,需要增加連接數.
MYSQL應用我在 /etc/my.cnf中修改了:
MYSQL應用
max_connections = 2000
MYSQL應用但是, 實際連接數一直被限制在 214:
MYSQL應用
mysql> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
1 row in set
MYSQL應用思考
MYSQL應用如果我設置連接小于214時,比如 200,那么實際連接數就是 200,也就是說,我的配置文件是沒有問題的.
MYSQL應用查 MySQL 官方文檔,里面說了:
MYSQL應用The maximum number of connections MySQL can support depends on the quality of the thread library on a given platform, the amount of RAM available, how much RAM is used for each connection, the workload from each connection, and the desired response time. Linux or Solaris should be able to support at 500 to 1000 simultaneous connections routinely and as many as 10,000 connections if you have many gigabytes of RAM available and the workload from each is low or the response time target undemanding. Windows is limited to (open tables × 2 + open connections) < 2048 due to the Posix compatibility layer used on that platform.
Increasing open-files-limit may be necessary. Also see Section 2.5, “Installing MySQL on Linux”, for how to raise the operating system limit on how many handles can be used by MySQL.
MYSQL應用大概意思是 MySQL 能夠支持的最大連接數量受限于操作系統,必要時可以增大 open-files-limit.換言之,連接數與文件打開數有關.
MYSQL應用解決方法
MYSQL應用
[root@sqzr ~]# ulimit -n
1024
MYSQL應用可知,操作系統最大文件描述符限制為 1024.
MYSQL應用更改 MySQL 在 Linux 的最大文件描述符限制,編輯 /usr/lib/systemd/system/mysqld.service
文件,在文件最后添加:
MYSQL應用
LimitNOFILE=65535
LimitNPROC=65535
MYSQL應用保存后,執行下面命令,使配置生效
MYSQL應用
$ systemctl daemon-reload
$ systemctl restart mysqld.service
MYSQL應用實際連接數到 2000 了,解決
MYSQL應用
mysql> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 2000 |
+-----------------+-------+
1 row in set
MYSQL應用參考
MYSQL應用https://dev.mysql.com/doc/refman/5.7/en/too-many-connections.html
MYSQL應用https://www.oschina.net/question/853151_241231
MYSQL應用總結
MYSQL應用以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對維易PHP的支持.
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/3347.html