這個問題的出現原因是system對程序打開files數量的限制問題。
用 ulimit -a 命令可以查看
[root@5 ~]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 4096
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 4096
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
可以看出,對open files的限制數是1024,我們可以通過修改這個值來增加可以打開的文件數。
******************************************************************
臨時修改:
將其改爲2048,用 ulimit -n 2048.
當你把open files的值增大到一定程度,你的Too many open files就不會再出現了。
******************************************************************
若要 長久 改變這兩個參數值,就要修改/ect/security/limits.conf,在文件中加上兩行:
* - nofile 102400
* - nproc 102400
******************************************************************