Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a FreeBSD 8 system running ZFS, with a MySQL 5.5 server which is about 355GB and projected to grow to be a couple of Terabytes.

MySQL is triggering errors about "Too many open files" on /etc/hosts.allow. We don't expressly use /etc/hosts.allow, but it is used by hosts_access(3) (libwrap.a), which is used by many things.

mysqld[1234]: warning: /etc/hosts.allow, line 15: cannot open /etc/hosts.allow: Too many open files

But when I check 't seem to be hitting any actual limits. The number of open files reported by kern.openfiles stays below 40,000 over a sustained period, and our limit is substantially higher:

# sysctl -a |grep files
kern.maxfiles: 204800
kern.maxfilesperproc: 184320
kern.openfiles: 38191

# ulimit -n
184320

Openfiles should be set to unlimited:

# grep openfiles /etc/login.conf
    :openfiles=unlimited:\

MySQL says it should be able to open 184320 file handles:

# mysqladmin variables | grep open_files_limit
| open_files_limit                              |     184320                |

And some information from the perspective of the MySQL user. I stopped mysql and hacked /usr/local/etc/rc.d/mysql-server to print out these variables, so this should represent the MySQL environment. Note that the number 184320 is consistent with the above.

# /usr/local/etc/rc.d/mysql-server.stefantest start
Starting mysql.
cpu time               (seconds, -t)  unlimited
file size           (512-blocks, -f)  unlimited
data seg size           (kbytes, -d)  33554432
stack size              (kbytes, -s)  524288
core file size      (512-blocks, -c)  unlimited
max memory size         (kbytes, -m)  unlimited
locked memory           (kbytes, -l)  unlimited
max user processes              (-u)  5547
open files                      (-n)  184320
virtual mem size        (kbytes, -v)  unlimited
swap limit              (kbytes, -w)  unlimited
sbsize                   (bytes, -b)  unlimited
pseudo-terminals                (-p)  unlimited

And, for easy reference here are the descriptions for the sysctls:

kern.maxfiles: Maximum number of files
kern.openfiles: System-wide number of open files
kern.maxfilesperproc: Maximum files allowed open per process

Related

share|improve this question
4  
ulimit isn't global, are you sure that's the same ulimit your MySQL is running with? – derobert Mar 4 at 20:06
Right, but isn't kern.maxfilesperproc global? I updated my question with some info from MySQL's perspective. – Stefan Lasiewski Mar 4 at 20:13
@StefanLasiewski: indeed it is, but ulimit is set per shell. And this can decrease the system-imposed limit further! – 0xC0000022L Mar 4 at 20:14
I see. I assumed that if ulimit is unset, then ulimit would inherit the value from kernel.maxfilesperproc. See forums.freebsd.org/showthread.php?t=1553 . But in my case, maybe it is set somewhere-- just can't find out where. – Stefan Lasiewski Mar 4 at 20:29
1  
So, can I see what the ulimit value is for the MySQL daemon, and can I change the ulimit value for the daemon without stopping the daemon? I know I can set ulimit in the startup script or the shell environment, but that would require that I interrupt the database. – Stefan Lasiewski Mar 4 at 20:31

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.