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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:41:30  来源:igfitidea点击:

Maximum number of processes in linux

linuxprocessoperating-system

提问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_maxcan 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_maxis 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-maxdivided by two, and that every thread counts toward a user's nproc limit. Thus, ps -u $USERmay make it appear that a user has not exhausted their nproc limit, but ps -L -u $USERcould 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.confas 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 unlimitedcommand to /etc/init.d/mongodbbut 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-maxis limiting mongodb max process count?

错误。这kernel.threads-max是限制 mongodb 最大进程数吗?