国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

CentOS 7中MySQL連接數被限制為214個的解決方法

2024-07-24 13:13:47
字體:
來源:轉載
供稿:網友

發現問題

最近在項目中遇到一個問題,由于連接數過多,提示 “Too many connections” ,需要增加連接數。

我在 /etc/my.cnf中修改了:

max_connections = 2000

但是, 實際連接數一直被限制在 214:

mysql/32297.html">mysql/139048.html">mysql> show variables like "max_connections";+-----------------+-------+| Variable_name | Value |+-----------------+-------+| max_connections | 214 |+-----------------+-------+1 row in set

思考

如果我設置連接小于214時,比如 200,那么實際連接數就是 200,也就是說,我的配置文件是沒有問題的。

查 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 能夠支持的最大連接數量受限于操作系統,必要時可以增大 open-files-limit。換言之,連接數與文件打開數有關。

解決方法

[root@sqzr ~]# ulimit -n1024

可知,操作系統最大文件描述符限制為 1024。

更改 MySQL 在 Linux 的最大文件描述符限制,編輯 /usr/lib/systemd/system/mysqld.service 文件,在文件最后添加:

LimitNOFILE=65535LimitNPROC=65535

保存后,執行下面命令,使配置生效

$ systemctl daemon-reload$ systemctl restart mysqld.service

實際連接數到 2000 了,解決

mysql> show variables like "max_connections";+-----------------+-------+| Variable_name  | Value |+-----------------+-------+| max_connections | 2000 |+-----------------+-------+1 row in set

參考

https://dev.mysql.com/doc/refman/5.7/en/too-many-connections.html

https://www.oschina.net/question/853151_241231

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對VeVb武林網的支持。


注:相關教程知識閱讀請移步到MYSQL教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沁阳市| 新乡县| 利辛县| 大同县| 樟树市| 邢台市| 阿克陶县| 红桥区| 海丰县| 华阴市| 利辛县| 东丰县| 禄丰县| 郓城县| 垦利县| 东兰县| 宣化县| 呼图壁县| 商都县| 正宁县| 镇远县| 永丰县| 三江| 德安县| 石柱| 女性| 读书| 密云县| 兴文县| 葫芦岛市| 岑巩县| 疏勒县| 乌拉特后旗| 阳泉市| 南丹县| 江华| 灵寿县| 县级市| 乌海市| 北宁市| 天气|