最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2017年06月29日 10:22:10   作者:折騰  
這篇文章主要給大家介紹了關(guān)于CentOS 7中MySQL連接數(shù)被限制為214個的解決方法,文中通過示例代碼介紹的非常詳細(xì),對大家具有一定的參考學(xué)習(xí)價值,需要的朋友們下面跟著小編來一起看看吧。

發(fā)現(xiàn)問題

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

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

max_connections = 2000

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

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

思考

如果我設(shè)置連接小于214時,比如 200,那么實際連接數(shù)就是 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 能夠支持的最大連接數(shù)量受限于操作系統(tǒng),必要時可以增大 open-files-limit。換言之,連接數(shù)與文件打開數(shù)有關(guān)。

解決方法

[root@sqzr ~]# ulimit -n
1024

可知,操作系統(tǒng)最大文件描述符限制為 1024。

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

LimitNOFILE=65535
LimitNPROC=65535

保存后,執(zhí)行下面命令,使配置生效

$ systemctl daemon-reload
$ systemctl restart mysqld.service

實際連接數(shù)到 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

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

相關(guān)文章

最新評論

关岭| 共和县| 仁布县| 拉孜县| 阳新县| 马关县| 三原县| 汉寿县| 措勤县| 浏阳市| 诸暨市| 鹤峰县| 安远县| 清水河县| 修水县| 惠东县| 东乌珠穆沁旗| 运城市| 延边| 嘉义县| 博客| 临汾市| 九台市| 天水市| 舞钢市| 习水县| 保亭| 峨山| 定南县| 邛崃市| 酒泉市| 舟曲县| 正定县| 保山市| 淮滨县| 南汇区| 上蔡县| 天津市| 河东区| 城口县| 桐城市|