Wednesday, March 30, 2022

Increase Open Files Limit

 

Increase Open Files Limit

To ensure good server performance, the total number of client connections, database files, and log files must not exceed the maximum file descriptor limit on the operating system (ulimit -n). Linux systems limit the number of file descriptors that any one process may open to 1,024 per process. On active database servers (especially production ones) it can easily reach the default system limit.

To increase this, edit /etc/security/limits.conf and specify or add the following:

1
2
3
mysql soft nofile 65535
 
mysql hard nofile 65535

This requires a system restart. Afterwards, you can confirm by running the following:

1
2
3
4
5
6
7
$ ulimit -Sn
 
65535
 
$ ulimit -Hn
 
65535

Optionally, you can set this via mysqld_safe if you are starting the mysqld process thru mysqld_safe,

1
2
3
[mysqld_safe]
 
open_files_limit=4294967295

or if you are using systemd,

1
2
3
4
5
6
7
8
9
10
11
sudo tee /etc/systemd/system/mariadb.service.d/limitnofile.conf <<EOF
 
[Service]
 
 
 
LimitNOFILE=infinity
 
EOF
 
sudo systemctl daemon-reload

No comments: