fork failed.: Cannot allocate memory

Posted 运维工匠实战(如果发现有错误请大家把正确的方法发送给我,方便

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了fork failed.: Cannot allocate memory相关的知识,希望对你有一定的参考价值。

 

在做压力测试时候:

[[email protected] ok]# webbench -c 5000 -t30 http://10.100.0.61/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://10.100.0.61/
5000 clients, running 30 sec.

Speed=176440 pages/min, 4025737 bytes/sec.
Requests: 88219 susceed, 1 failed.
[[email protected] ok]# webbench -c 50000 -t30 http://10.100.0.61/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://10.100.0.61/
50000 clients, running 30 sec.
problems forking worker no. 6594
fork failed.: Cannot allocate memory
bash: fork: Cannot allocate memory
bash: fork: Cannot allocate memory
bash: fork: Cannot allocate memory
bash: fork: Cannot allocate memory
bash: fork: Cannot allocate memory
bash: fork: Cannot allocate memory
bash: fork: Cannot allocate memory
bash: fork: Cannot allocate memory
bash: fork: Cannot allocate memory
bash: fork: Cannot allocate memory
bash: fork: Cannot allocate memory
....
bash: cannot make pipe for command substitution: Too many open files

 查询pid_max值:

[[email protected] ok]# sysctl kernel.pid_max
kernel.pid_max = 32768

 修改pid_max的值:

[[email protected] ok]# sysctl -w kernel.pid_max=60000
kernel.pid_max = 60000
[[email protected] ok]# sysctl kernel.pid_max
kernel.pid_max = 60000

 

[[email protected] ok]# echo ‘kernel.pid_max=9999‘ >>/etc/sysctl.conf 
[[email protected] ok]# sysctl -p
kernel.pid_max = 9999

 

以上是关于fork failed.: Cannot allocate memory的主要内容,如果未能解决你的问题,请参考以下文章

安装composer后报错proc_open(): fork failed - Cannot allocate memory

runtime/cgo: pthread_create failed: Resource temporarily unavailable or fork: Cannot allocate mem

-bash: fork: Cannot allocate memory

-bash:fork:Cannot allocate memory 问题的处理

redis : Can't save in background: fork: Cannot allocate memory

pid max导致fork: Cannot allocate memory 的处理