内核参数调整 limit
配置文件路径:/etc/security/limits.conf
常用参数调整:
* soft nofile 65536 * hard nofile 102400 * soft nproc 65535 * hard nproc 655350 * soft memlock unlimited * hard memlock unlimited
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
- nofile - max number of open file descriptors
- nproc - max number of processes
soft 值必须小于 hard;超出soft警告,超出hard异常;
注意:如果在/etc/security/limits.d/下进行了配置,将会覆盖 /etc/security/limits.conf 的配置参数;
配置生效:
重启系统 或者 重启shell进程
[root@ckm01 ~]# 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) 7736 max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 65536 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 65535 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited [root@ckm01 ~]# ulimit -Ha core file size (blocks, -c) unlimited data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 7736 max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 102400 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) unlimited cpu time (seconds, -t) unlimited max user processes (-u) 655350 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
要使 limits.conf 文件配置生效,必须要确保 pam_limits.so 文件被加入到启动文件中。查看 /etc/pam.d/login 文件中有:
session required /lib/security/pam_limits.so
注意:Centos 7并未发现该参数,配置 limits.conf 依然生效;