/etc/security/limits.conf 配置

<pre name="code" class="python">* 		soft 	nofile 		65535 
* 		hard 	nofile 		65535 

* 		soft 	nproc 		65535 
* 		hard 	nproc 		65535 


soft nofile表示软限制,hard nofile表示硬限制,软限制要小于等于硬限制。


soft 	nproc  hard 	nproc  进程数


zjzc01:/root# 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) 7808
max locked memory       (kbytes, -l) 64
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) 7808
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


缺省open files  是1024


修改为:

# End of file
 * 		soft 	nofile 		6553 
 * 		hard 	nofile 		7553


open files                      (-n) 6553


root soft nofile 1000 
root hard nofile 1200
soft nofile表示软限制,hard nofile表示硬限制,软限制要小于等于硬限制。上面两行语句表示,root用户的软限制为1000,硬限制为1200,即表示root用户能打开的最大文件数量为1000,不管它开启多少个shell。

type:有 soft,hard 和 -,soft 指的是当前系统生效的设置值。hard 表明系统中所能设定的最大值。soft 的限制不能比hard 限制高。用 - 就表明同时设置了 soft 和 hard 的值。


* 		soft 	nproc 		65530
* 		hard 	nproc 		65531

max user processes              (-u) 65531

通过ulimit -n修改,如执行命令ulimit -n 1000,则表示将当前shell的当前用户所有进程能打开的最大文件数量设置为1000.



                                    
原文地址:https://www.cnblogs.com/hzcya1995/p/13350918.html