max_connections 选项不适用于 mysqld
max_connections option not working with mysqld
我在 /etc/my.conf
中设置了 max_connections=2000
并重新启动了 mysqld
但仍然 max_connections
似乎卡在了 412
mysql> SHOW VARIABLES LIKE "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 412 |
+-----------------+-------+
1 row in set (0.01 sec)
mysql>
我也试过重启 mysqld
post
mysql> SET GLOBAL max_connections = 2000;
但我仍然从查询 SHOW VARIABLES LIKE "max_connections";
中得到 max_connections | 412
我通过更改系统级别对打开文件数的限制解决了这个问题。
检查系统级别。 运行 命令 ulimit -a
输出将是
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 31168
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1012
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 4096
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
open files
限制必须大于 max_connecitons
的值
要更改它,请执行以下操作
sudo nano /etc/security/limits.conf
和add/edit
* hard nofile 4096
* soft nofile 4096
现在re-login到服务器并重新启动mysqld
并检查
mysql> SHOW VARIABLES LIKE "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 2000 |
+-----------------+-------+
1 row in set (0.01 sec)
mysql>
为服务文件创建覆盖
systemctl edit mysql.service
添加以下内容
[Service]
LimitNOFILE=4096
重新启动 MySQL 服务器
service mysql restart
我在 /etc/my.conf
中设置了 max_connections=2000
并重新启动了 mysqld
但仍然 max_connections
似乎卡在了 412
mysql> SHOW VARIABLES LIKE "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 412 |
+-----------------+-------+
1 row in set (0.01 sec)
mysql>
我也试过重启 mysqld
post
mysql> SET GLOBAL max_connections = 2000;
但我仍然从查询 SHOW VARIABLES LIKE "max_connections";
max_connections | 412
我通过更改系统级别对打开文件数的限制解决了这个问题。
检查系统级别。 运行 命令 ulimit -a
输出将是
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 31168
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1012
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 4096
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
open files
限制必须大于 max_connecitons
要更改它,请执行以下操作
sudo nano /etc/security/limits.conf
和add/edit
* hard nofile 4096
* soft nofile 4096
现在re-login到服务器并重新启动mysqld
并检查
mysql> SHOW VARIABLES LIKE "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 2000 |
+-----------------+-------+
1 row in set (0.01 sec)
mysql>
为服务文件创建覆盖
systemctl edit mysql.service
添加以下内容
[Service]
LimitNOFILE=4096
重新启动 MySQL 服务器
service mysql restart