我在FreeBSD 10.1-RELEASE上遇到有关每个进程的openfiles限制的问题。为了证明这一点,我使用python脚本生成虚拟文件并打开这些文件。
中提供的脚本要生成1M文件,请执行命令
# mkdir -p /tmp/1
# python dummyFileGenerator.py -d /tmp/1 -n 1000000 -r 1
然后,按
加载所有文件# python dummyFileLoader.py -d /tmp/1 -n 1000000 -r 1
加载32766文件后显示打开文件错误
retry openfile 32766
Traceback (most recent call last):
File "dummyFileLoader.py", line 74, in <module>
File "dummyFileLoader.py", line 59, in openfile
IOError: [Errno 24] Too many open files: '/tmp/1/00/00/7f/fd'
我尝试更改 maxfile 但未解决
# sysctl -a|grep maxfiles
kern.maxfiles: 1000000
kern.maxfilesperproc: 1000000
# ulimit -a
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) 6670
open files (-n) 58284
virtual mem size (kbytes, -v) unlimited
swap limit (kbytes, -w) unlimited
sbsize (bytes, -b) unlimited
pseudo-terminals (-p) unlimited
有任何想法吗?