开发者社区> 技术小阿哥> 正文

解决-bash: fork: retry: Resource temporarily unavailable错误

简介:
+关注继续查看

http://www.nginx.cn/3002.html


登陆不了服务器
The server refused to start a shell.

登陆服务器后执行ls命令报错:


1

2

$ls

-bash: fork: retry: Resource temporarily unavailable


上面这段错误提示的本质是Linux操作系统无法创建更多进程,导致出错。
因此要解决这个问题需要修改Linux允许创建更多的进程。

修改Linux最大进程数

我们可以通过ulimit -a来查看当前Linux系统的一些系统参数。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

$ 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) 62357

max locked memory       (kbytes, -l) 64

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) 10240

cpu time               (seconds, -t) unlimited

max user processes              (-u) 1024

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited


在上面这些参数中,通常我们关注得比较多的是一个进程可打开的最大文件数,即open files。
系统允许创建的最大进程数量即是max user processes 这个参数。
我们可以使用 ulimit -u 4096 修改max user processes的值,但是只能在当前终端的这个session里面生效,重新登录后仍然是使用系统默认值。
正确的修改方式是修改/etc/security/limits.d/90-nproc.conf文件中的值。


1

2

3

4

5

6

$ cat /etc/security/limits.d/90-nproc.conf

# Default limit for number of user's processes to prevent

# accidental fork bombs.

# See rhbz #432903 for reasoning.

 

*          soft    nproc    4096


我们只要修改上面文件中的4096这个值,即可。



本文转自 liqius 51CTO博客,原文链接:http://blog.51cto.com/szgb17/1982087,如需转载请自行联系原作者

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
未解决:dpkg-source: error: aborting due to unexpected upstream changes, see /tmp/-1.diff.rm5mTN
未解决:dpkg-source: error: aborting due to unexpected upstream changes, see /tmp/-1.diff.rm5mTN
18 0
git sync fatal: Authentication failed for https://github.com/ did not exit cleanly (exit code 128)
git sync fatal: Authentication failed for https://github.com/ did not exit cleanly (exit code 128)
91 0
jps查看进程出现「xxxx -- process information unavailable」
jps查看进程出现「xxxx -- process information unavailable」
120 0
Docker Swarm 解决报错Error response from daemon: rpc error: code = Unavailable desc = connection error:
本文是博主学习docker swarm遇到的问题记录,希望对大家有所帮助。
685 0
解析Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]
解析Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]
137 0
Job for named.service failed because the control process exited with error code.怎么解决
本篇内容记录了如何解决Job for named.service failed because the control process exited with error code.的问题。
1568 0
pip 安装库失败问题:Retrying (Retry(total=4, connect=None, read=None, redirect=None, status =None)),原因及解决办法
pip 安装库失败问题:Retrying (Retry(total=4, connect=None, read=None, redirect=None, status =None)),原因及解决办法
2713 0
Starting a Gradle Daemon, 5 busy and 1 incompatible and 1 stopped Daemons could not be reused, use --status for details FAILURE: Build failed with an
执行gradle build出的问题,查看hs_err_pid11064.log日志文件发现,是电脑的RAM不足导致
3643 0
文章
问答
文章排行榜
最热
最新
相关电子书
更多
Substitution failure is not an
立即下载
Substitution failure
立即下载
低代码开发师(初级)实战教程
立即下载