linux中的最大进程数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9361816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maximum number of processes in linux
提问by kdexter
What is the maximum limit to the number of processes possible in a linux system? How can we find it ?
linux系统中可能的进程数的最大限制是多少?我们怎样才能找到它?
回答by kdexter
Your kernel should export this information in procfs
:
您的内核应该将此信息导出到procfs
:
cat /proc/sys/kernel/pid_max
This is the maximum number of unique process identifiers your system can support.
这是您的系统可以支持的唯一进程标识符的最大数量。
Since it is a file, /proc/sys/kernel/pid_max
can be inspected from any capable programming language.
由于它是一个文件,/proc/sys/kernel/pid_max
因此可以通过任何有能力的编程语言进行检查。
回答by Lester Cheung
sysctl kernel.pid_max
sysctl kernel.pid_max
or
或者
cat /proc/sys/kernel/pid_max
cat /proc/sys/kernel/pid_max
As suggested by Ninefingers.
正如九指的建议。
For completeness, you can change it temporarily by writing to /proc/syskernel/pid_max or permanently by adding:
为了完整起见,您可以通过写入 /proc/syskernel/pid_max 来临时更改它,或者通过添加以下内容来永久更改它:
kernel.pid_max = 4194303
内核.pid_max = 4194303
to /etc/sysctl.conf. 4194303 is the maximum limit for x86_64 and 32767 for x86.
到 /etc/sysctl.conf。4194303 是 x86_64 的最大限制,x86 是 32767。
回答by Ankit Singhal
Short answer to your question : Number of process possible in the linux system is UNLIMITED.
简短回答您的问题:Linux 系统中可能的进程数是无限的。
But there is a limit on number of process per user(except root who has no limit).
但是每个用户的进程数是有限制的(root 没有限制除外)。
And you can check your user limits with below command (apposite to "max user processes").
您可以使用以下命令检查您的用户限制(适用于“最大用户进程”)。
$ 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) 256447
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 128000
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) 500000
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
If you want to increase the limit on number of process for a particular user(for eg: hadoop ) , you need to make below entry in /etc/security/limits.conf
如果要增加特定用户的进程数限制(例如: hadoop ),则需要在/etc/security/limits.conf中输入以下条目
hadoop - nproc 500000
回答by Andy Grimm
kernel.pid_max
is a limiting factor, but at least as important is kernel.threads-max
. It's worth noting that the default nproc ulimit for each user is kernel.threads-max
divided by two, and that every thread counts toward a user's nproc limit. Thus, ps -u $USER
may make it appear that a user has not exhausted their nproc limit, but ps -L -u $USER
could tell a very different story.
kernel.pid_max
是一个限制因素,但至少同样重要kernel.threads-max
。值得注意的是,每个用户的默认 nproc ulimitkernel.threads-max
除以 2,并且每个线程都计入用户的 nproc 限制。因此,ps -u $USER
可能会使用户看起来没有用尽他们的 nproc 限制,但ps -L -u $USER
可以讲述一个非常不同的故事。
回答by hardc0der
Did you mean that a mongodb process can only create with max nproc = threads-max / 2
?
您的意思是 mongodb 进程只能创建max nproc = threads-max / 2
吗?
Because i'm trying to increase nproc as unlimited.
因为我试图将 nproc 增加为无限制。
I tried to put limits on /etc/security/limits.conf
as like this:
mongodb soft nproc unlimited
mongodb hard nproc unlimited
mongodb soft nofile 50000
mongodb hard nofile 50000
mongodb soft sigpending unlimited
mongodb hard sigpending unlimited
However it didn'r reflect on mongodb process even after complete reboot.
我试图/etc/security/limits.conf
像这样设置限制:
mongodb soft nproc unlimited
mongodb hard nproc unlimited
mongodb soft nofile 50000
mongodb hard nofile 50000
mongodb soft sigpending unlimited
mongodb hard sigpending unlimited
但是,即使在完全重新启动后,它也没有反映在 mongodb 进程中。
Then i tried to put ulimit -u unlimited
command to /etc/init.d/mongodb
but after i tried to start with this file i got
然后我尝试将ulimit -u unlimited
命令放入/etc/init.d/mongodb
但在我尝试使用此文件开始后我得到了
/etc/init.d/mongodb: 67: ulimit: Illegal option -u
/etc/init.d/mongodb: 67: ulimit: Illegal option -u
error. Is this kernel.threads-max
is limiting mongodb max process count?
错误。这kernel.threads-max
是限制 mongodb 最大进程数吗?