更改系统的 open files 最大限制,一般都是通过以下方法来做:
第一步:打开终端并敲入以下命令以打开一个配置文件
$: sudo gedit /etc/security/limits.conf
第二步:在打开的文件中增加以下几行配置并保存关闭
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
第三步:重启,并重新登录,打开终端后敲入以下命令进行验证
$ ulimit -a
…
open files (-n) 65536
…
这样几步就可大功告成!
但是,以上这些操作只能在 Ubuntu 16.04 及以下版本才能有效——到了 Ubuntu 18.04,却不起作用?百思不得其解,各种百度后无果,只好打开必应进行一番 E 文搜索,结果找到一篇老外的文章(https://superuser.com/questions/1200539/cannot-increase-open-file-limit-past-4096-ubuntu)。其中最有用的几句如下:
In Summary
- If you want to increase the limit shown by ulimit -n, you should:
Modify /etc/systemd/user.conf and /etc/systemd/system.conf with the following line (this takes care of graphical login):
DefaultLimitNOFILE=65535
- Modify /etc/security/limits.conf with the following lines (this takes care of non-GUI login):
* hard nofile 65535
* soft nofile 65535
最后特别提醒大家一句,这三个地方的文件改好之后,一定要重启系统才得以生效哟!!
原文链接:https://blog.csdn.net/zhulx_sz/article/details/88309367