LoginSignup
1
0

More than 5 years have passed since last update.

max_connectionsの設定値が反映されない。

Posted at

環境

Ubuntu: 16.04.5
MySQL: 5.7.23

事象

MySQLの同時接続数(max_connections)をデフォルトから10000に引き上げるため、以下内容でcnfファイルを修正したにもかかわらず、

/etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]
...
max_connections        = 10000
...

設定値が反映されていませんでした。

mysql> SHOW GLOBAL VARIABLES LIKE 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 214   |
+-----------------+-------+
1 row in set (0.01 sec)

原因

max_connectionsはファイルディスクリプタの数に依存するのですが、こちらがデフォルト(1024)のままだったことが原因でした。

解決方法

ファイルディスクリプタの数は /etc/security/limits.confで変更可能ですが、UbuntuではサービスファイルにLimitNOFILEを指定することでも対応可能です。

/lib/systemd/system/mysql.service
...
[Service]
...
LimitNOFILE=65535
mysql> SHOW GLOBAL VARIABLES LIKE 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 10000 |
+-----------------+-------+
1 row in set (0.00 sec)
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0