MariaDB on CentOS 7 – “Error in accept: Too many open files”

By default is seems the soft and hard open files limits on MariaDB in CentOS 7 are 1024 and 4096 respectfully. You can see these limits by first getting the process ID:

cat /var/run/mariadb/mariadb.pid

And then looking at the limits in the proc filesystem:

cat /proc/<processID>/limits
[root@web1 ~]# cat /proc/6548/limits

Limit                     Soft Limit           Hard Limit           Units

Max cpu time              unlimited            unlimited            seconds

Max file size             unlimited            unlimited            bytes

Max data size             unlimited            unlimited            bytes

Max stack size            8388608              unlimited            bytes

Max core file size        0                    unlimited            bytes

Max resident set          unlimited            unlimited            bytes

Max processes             31209                31209                processes

Max open files            1024                 4096                 files

Max locked memory         65536                65536                bytes

Max address space         unlimited            unlimited            bytes

Max file locks            unlimited            unlimited            locks

edit the file

sudo vi /usr/lib/systemd/system/mariadb.service

Under the “[Service]” section add the following line:

LimitNOFILE=infinity

Restart the MariaDB service:

/sbin/service mariadb restart