Linux 线程数限制,Suse,redhat等

本文介绍Linux 线程数限制,只要在sysctl.conf和limits.conf两个配置文件里。另外在redhat 7.5+和suse 12,又增加了TaskMax限制。

检查方法

cat /proc/sys/kernel/threads-max
cat /proc/sys/vm/max_map_count
cat /etc/security/limits.d/90-nproc.conf 
cat /proc/sys/kernel/pid_max

也可以

[root@localhost ~]# sysctl -a | grep -i thread
kernel.threads-max = 62300
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.enp0s3.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
sysctl: reading key "net.ipv6.conf.virbr0.stable_secret"
sysctl: reading key "net.ipv6.conf.virbr0-nic.stable_secret"
vm.nr_pdflush_threads = 0
[root@localhost ~]#

[root@localhost ~]# sysctl -a | grep -i pid
kernel.cad_pid = 1
kernel.core_uses_pid = 1
kernel.ns_last_pid = 4786
kernel.pid_max = 32768
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.enp0s3.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
sysctl: reading key "net.ipv6.conf.virbr0.stable_secret"
sysctl: reading key "net.ipv6.conf.virbr0-nic.stable_secret"
user.max_pid_namespaces = 31150
[root@localhost ~]#


[root@localhost ~]# 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) 31150
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) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31150
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[root@localhost ~]#

修改方法

vi /etc/sysctl.conf

vi /etc/security/limits.conf

vi etc/security/limits.d/90-nproc.conf 

参考

Suse 12和redhat 7.5+ 修改任务数TasksMax,DefaultTasksMax,UserTasksMax等全局、用户的配置

https://blog.csdn.net/shy_snow/article/details/106762604