MYsql5.23 failed to set the maximum number of connections

The number of MySQL connections under RHEL\CentOS 7 is limited to 214
Way Lau's Personal Site 2015-07-09 273 Read
mysql centos CentOS MySQL
problem In the

project , due to the excessive number of connections, the prompt "Too many connections" needs to be increased.

I modified max_connections = 2000 in /etc/my.cnf

but the actual number of connections has been limited to 214

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

MySQL max_connections is always 214. Can't make it bigger?
Environment

    CentOS 7.1
    MySQL 5.6.25

Thinking

If I set the connection to be less than 214, such as 200, then the actual number of connections is 200, that is to say, there is no problem with my configuration file.

Check MySQL official documentation, which says

    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.

It probably means that the maximum number of connections that MySQL can support is limited by the operating system, and open-files-limit can be increased if necessary. In other words, the number of connections is related to the number of open files.
Solution

Execute

[root@emsc ~]# ulimit -n to

know that the maximum file descriptor limit of the operating system is 1024. Adding

open_files_limit = 65535 to the configuration file

does not actually take effect. To

change the maximum file descriptor limit of MySQL in Linux, edit / usr/lib/systemd/system/mysqld.service file, add at the end of the file:

LimitNOFILE=65535
LimitNPROC=65535

After saving, execute the following command to make the configuration take effect

$ systemctl daemon-reload
$ systemctl restart mysqld.service The

actual number of connections to 2000 Now , solve

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

reference

    http://dev.mysql.com/doc/refman/5.7/en/too-many-connections.html
    http://www.oschina.net/question/853151_241231

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326357649&siteId=291194637