D
D
Dmitry Chilikin2017-02-06 14:51:56
MySQL
Dmitry Chilikin, 2017-02-06 14:51:56

How to fix Mysql error: 24 Too many open files?

Good afternoon!
Dedicated VPS server, OS Ubuntu 16.04.1 LTS, NGINX+APACHE+MYSQL. About 15 working sites (CMS Bitrix) are located on the server. Recently, the MySQL error: 24 Too many open files has become more frequent. Searching for information on Google, incl. and on the Toaster took the following actions:
1. Increased the limit of open files in the MySQL configuration: file my.cnf
section [mysqld]
open_files_limit = 4098
2. Increased the limit in the system: file /etc/security/limits.conf

mysql   soft    nofile  24000
mysql   hard    nofile  32000

or
*   soft    nofile  24000
*   hard    nofile  32000

3. Increased in the kernel configuration: file /etc/sysctl.conf
fs.file-max = 999999
System restart. And .... Again, nothing.
MySQL Answer:
mysql> show variables like 'open_files_limit';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| open_files_limit | 1024  |
+------------------+-------+
1 row in set (0.01 sec)

System settings not applied:
[email protected]:~# ulimit -Sn
1024
[email protected]:~# ulimit -Hn
4096

Check open MySQL files by command:
sudo lsof -u mysql | wc -l 
986

What else can be done? how to set limits on MySQL open threads?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Smithson, 2017-02-06
@peacock

As far as I understand, you already have systemd there.
And it is configured differently:
In the file /etc/systemd/system/multi-user.target.wants/mysql.service (I don’t remember exactly how the path looks in 16.4)
in the [Service] section, write LimitNOFILE=16384 (if necessary, the file and create a section! You can take some file from there as a template, cron.service, for example)
and

sudo systemctl daemon-reload 
sudo systemctl restart mysql

D
Dmitry Chekanov, 2018-07-06
@LanDer931

/etc/systemd/system/multi-user.target.wants/mysql.service

[Service]
LimitNOFILE=999999
LimitNPROC=999999
TasksMax=infinity

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question