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
- This is possibly related to a ZFS on Nexenta question on ServerFault: Why is MySQL unable to open hosts.allow/hosts.deny?
- Also see this similar issue on the FreeBSD forums: [EMFILE] Too many open files
kern.maxfilesperprocglobal? I updated my question with some info from MySQL's perspective. – Stefan Lasiewski Mar 4 at 20:13ulimitis set per shell. And this can decrease the system-imposed limit further! – 0xC0000022L Mar 4 at 20:14ulimitis unset, thenulimitwould inherit the value fromkernel.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:29ulimitin the startup script or the shell environment, but that would require that I interrupt the database. – Stefan Lasiewski Mar 4 at 20:31