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. MYSQL应用大概意思是 MySQL 能够支持的最大连接数量受限于操作系统,必要时可以增大 open-files-limit.换言之,连接数与文件打开数有关. MYSQL应用解决方法 MYSQL应用
[root@sqzr ~]# ulimit -n
1024
MYSQL应用可知,操作系统最大文件描述符限制为 1024. MYSQL应用更改 MySQL 在 Linux 的最大文件描述符限制,编辑 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的支持. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |