《MYSQL教程CentOS 7中MySQL連接數(shù)被限制為214個(gè)的解決方法》要點(diǎn):
本文介紹了MYSQL教程CentOS 7中MySQL連接數(shù)被限制為214個(gè)的解決方法,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
MYSQL應(yīng)用發(fā)現(xiàn)問(wèn)題
MYSQL應(yīng)用最近在項(xiàng)目中遇到一個(gè)問(wèn)題,由于連接數(shù)過(guò)多,提示 “Too many connections” ,需要增加連接數(shù).
MYSQL應(yīng)用我在 /etc/my.cnf中修改了:
MYSQL應(yīng)用
max_connections = 2000
MYSQL應(yīng)用但是, 實(shí)際連接數(shù)一直被限制在 214:
MYSQL應(yīng)用
mysql> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
1 row in set
MYSQL應(yīng)用思考
MYSQL應(yīng)用如果我設(shè)置連接小于214時(shí),比如 200,那么實(shí)際連接數(shù)就是 200,也就是說(shuō),我的配置文件是沒(méi)有問(wèn)題的.
MYSQL應(yīng)用查 MySQL 官方文檔,里面說(shuō)了:
MYSQL應(yīng)用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應(yīng)用大概意思是 MySQL 能夠支持的最大連接數(shù)量受限于操作系統(tǒng),必要時(shí)可以增大 open-files-limit.換言之,連接數(shù)與文件打開數(shù)有關(guān).
MYSQL應(yīng)用解決方法
MYSQL應(yīng)用
[root@sqzr ~]# ulimit -n
1024
MYSQL應(yīng)用可知,操作系統(tǒng)最大文件描述符限制為 1024.
MYSQL應(yīng)用更改 MySQL 在 Linux 的最大文件描述符限制,編輯 /usr/lib/systemd/system/mysqld.service
文件,在文件最后添加:
MYSQL應(yīng)用
LimitNOFILE=65535
LimitNPROC=65535
MYSQL應(yīng)用保存后,執(zhí)行下面命令,使配置生效
MYSQL應(yīng)用
$ systemctl daemon-reload
$ systemctl restart mysqld.service
MYSQL應(yīng)用實(shí)際連接數(shù)到 2000 了,解決
MYSQL應(yīng)用
mysql> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 2000 |
+-----------------+-------+
1 row in set
MYSQL應(yīng)用參考
MYSQL應(yīng)用https://dev.mysql.com/doc/refman/5.7/en/too-many-connections.html
MYSQL應(yīng)用https://www.oschina.net/question/853151_241231
MYSQL應(yīng)用總結(jié)
MYSQL應(yīng)用以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,如果有疑問(wèn)大家可以留言交流,謝謝大家對(duì)維易PHP的支持.
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/3347.html