too many open files

压测遇到这个问题,每次都查,记录一下:

系统分配文件数太少,临时修改方案:

ulimit -n 2048

永久配置:

vim /etc/security/limits.conf 

底部配置:

# End of file
* soft nofile 100000
* hard nofile 100000
* soft memlock unlimited
* hard memlock unlimited
* hard nproc 100000
* soft nproc 100000

第一项配置用户,*代表所有用户,soft和hard两种都要配置,如果数量相同,第二项配“-”

by the way

如果想查看某个进程打开的文件可以用命令

#18754是进程号
lsof -p 18754

计数:

lsof -p 18754 | wc -l
上一篇:Python之路-文件操作(py3)


下一篇:favicon.ico--网站标题小图片二三事