問題解決:bash: fork: retry: Resource temporarily unavailable

linux報錯:html

  bash: fork: retry: Resource temporarily unavailablelinux

無論是執行什麼nginx

 

登錄不了服務器
The server refused to start a shell.shell

登錄服務器後執行ls命令報錯:bash

$ls
-bash: fork: retry: Resource temporarily unavailable

上面這段錯誤提示的本質是Linux操做系統沒法建立更多進程,致使出錯。
所以要解決這個問題須要修改Linux容許建立更多的進程。服務器

修改Linux最大進程數session

咱們能夠經過ulimit -a來查看當前Linux系統的一些系統參數。ide

$ 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文件中的值。spa

$ 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這個值,便可。操作系統

 

除非註明,本站文章均爲: nginx.cn原創,轉載請註明本文地址: http://www.nginx.cn/3002.html

--完--

相關文章
相關標籤/搜索