Gone are the days where simply changing /etc/my.cnf
would be sufficient. Enter the new systemd world.
systemd itself has a limit that controls how many files a service can open, regardless if what you configure in /etc/my.cnf
or /etc/security/limits.conf
.
To increase the open files limit in MariaDB running on a RHEL or CentOS 7 with systemd, do the following.
First, create a new directory that will hold the MariaDB service changes in systemd. By making your changes here, you’ll make sure that package upgrades that would/could overwrite the mariadb.service file don’t remove your own changes.
$ mkdir -p /etc/systemd/system/mariadb.service.d/
Next, configure systemd so that the MariaDB service can open more files.
$ nano /etc/systemd/system/mariadb.service.d/limits.conf [Service] LimitNOFILE=65535
In order for systemd to be aware of those changes, you have to reload the systemd daemon. This only reloads the configs that systemd knows about, it does not restart any actual service.
$ systemctl daemon-reload
The above tells systemd that MariaDB can open 10000 files of it wants. Restart the MariaDB service now to make those changes stick.
$ systemctl restart mariadb
Выполняем запрос к базе данных
SHOW VARIABLES LIKE 'Open_files_limit';
Получаем значение
+------------------+-------+ | Variable_name | Value | +------------------+-------+ | open_files_limit | 65535 | +------------------+-------+ 1 row in set (0.00 sec)
And you’re done.
Increase the value in /etc/systemd/system/mariadb.service.d/limits.conf
if needed.
These changes are also «documented» in the mariadb.service
service file in systemd.
$ cat /usr/lib/systemd/system/mariadb.service ... # It's not recommended to modify this file in-place, because it will be # overwritten during package upgrades. If you want to customize, the # best way is to create a file "/etc/systemd/system/mariadb.service", # containing # .include /lib/systemd/system/mariadb.service # ...make your changes here... # or create a file "/etc/systemd/system/mariadb.service.d/foo.conf", # which doesn't need to include ".include" call and which will be parsed # after the file mariadb.service itself is parsed. # # For more info about custom unit files, see systemd.unit(5) or # http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F # For example, if you want to increase mariadb's open-files-limit to 10000, # you need to increase systemd's LimitNOFILE setting, so create a file named # "/etc/systemd/system/mariadb.service.d/limits.conf" containing: # [Service] # LimitNOFILE=10000 # Note: /usr/lib/... is recommended in the .include line though /lib/... # still works. # Don't forget to reload systemd daemon after you change unit configuration: # root> systemctl --system daemon-reload
Just another thing to keep in mind.