linux文件描述符数量的坑

ulimit -n  查看 单进程或线程,可打开的最大文件描述符数

通过ulimit -n 10240 设置文件描述符数:

(当前shell生效,这真是个坑啊)

永久生效:(需要重启系统,也是个坑,好好的系统是不会去重启的)
[root@linux2 ~]# cat /etc/security/limits.conf
*   soft    nofile   65535
*   hard   nofile   65535
*   soft   nproc   65535
*   hard   nproc   65535

(设置多少自行更改,这里只是个示范)

系统同一时刻最大打开的文件数目:(这些和上面的也是相互约束的)
[root@linux2 ~]# cat /proc/sys/fs/file-max
98267

原文地址:https://www.cnblogs.com/fanxuanhui-linux/p/6242240.html