Ubuntu 18.04 MariaDB 10.2 Too many open files

On my computer running Ubuntu 18.04, MriaDB stopped working. PHP application i run on my computer failed with error

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ok_test.feeds' doesn't exist (SQL: select * from `feeds` where `processed` = 0)

Application can’t find the table. So i tried to login to MySQL and see if table is there or not. But i get error

boby@sok-01:~$ mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2504
Server version: 10.2.30-MariaDB-1:10.2.30+maria~bionic-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
ERROR 1018 (HY000): Can't read dir of '.' (errno: 24 "Too many open files")
MariaDB [(none)]>

Next i checked if this is due to any MySQL upgrade. I found MySQL got updated today

root@sok-01:~# grep mariadb /var/log/dpkg.log
2019-12-13 08:02:46 status triggers-pending mariadb-server-10.2:amd64 1:10.2.29+maria~bionic
2019-12-13 08:02:46 upgrade mariadb-common:all 1:10.2.29+maria~bionic 1:10.2.30+maria~bionic
2019-12-13 08:02:46 status half-configured mariadb-common:all 1:10.2.29+maria~bionic
2019-12-13 08:02:46 status unpacked mariadb-common:all 1:10.2.29+maria~bionic
2019-12-13 08:02:46 status half-installed mariadb-common:all 1:10.2.29+maria~bionic

To fix this error, run

systemctl edit mysql

This wil open a text editor. Add following

[Service]
LimitNOFILE=8192

Save and quit the editor. Restart MaraDB with

systemctl restart mysql

MySQL will work properly now. systemctl edit mysql will create file /etc/systemd/system/mysql.service.d/override.conf

root@sok-01:~# cat /etc/systemd/system/mysql.service.d/override.conf 
[Service]
LimitNOFILE=8192

root@sok-01:~#
Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *