Could not increase number of max_open_files to more than X

Are you seeing the “Could not increase number of max_open_files to more than X” warning when restarting MySQL in WHM? I was seeing this warning even after changing open_file_limits in my.cnf.

The open_file_limits seemed to be stuck despite any changes I made, but I figured out the solution. Hopefully, this mini tutorial will save you a lot of time. Note: I’m using a VPS with CentOS and connecting with PuTTY.


Step 1

Assuming you are root in the terminal, type:

nano /etc/systemd/system/mariadb.service.d/override.conf

or (Depending on which you are using – I’m using MariaDB)

nano /etc/systemd/system/mysqld.service.d/override.conf

mysql-override

Step 2

Now we can edit the file, which should be blank at the moment. Type:

[Service]
LimitNOFILE=X

(X being the value you want)

limit-no-file-override

Step 3, 4, & 5

Type:

Ctrl+X
Y
Enter

limit-no-file-override-save
limit-no-file-override-save

Step 6 & 7

Now to check our work. Type:

cat /etc/systemd/system/mariadb.service.d/override.conf

or (Depending on which you are using – I’m using MariaDB)

cat /etc/systemd/system/mysqld.service.d/override.conf

limit-no-file-override-check

This will display what’s in the file. If incorrect, simply go back and edit the file again. If it’s correct, type:

systemctl daemon-reload

systemctl-daemon-reload

Step 8

Time to restart MySQL. I prefer to restart from WHM to see there are no more warnings. If you want a quick terminal MySQL restart, type:

service mysql restart

This now displays when I restart through WHM.

whm-mysql-restart

One last check you can do after restarting MySQL, type:

mysql
show global variables like ‘%open_files_limit%’;
\q

root-mysql-open-files-limit

If this post was helpful, I highly recommend checking out this Optimized My.cnf Configuration on GitHub.

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments