Linux vps错误bash: fork: Cannot allocate memory
  • 在linux vps,偶尔会出现错误bash: fork: Cannot allocate memory。这是vps的bug,虽然你可能还有很多内存没有用完。怎么办?最理想的办法就是重启vps,不想重启怎么办?看下面的操作过程:

    [root@www.654z.com]# more database.php
    -bash: fork: Cannot allocate memory
    [root@www.654z.com]# free
    -bash: fork: Cannot allocate memory
    [root@www.654z.com]# reboot
    -bash: fork: Cannot allocate memory
    [root@www.654z.com]# service httpd stop
    -bash: fork: Cannot allocate memory
    [root@www.654z.com]# service httpd stop
    -bash: fork: Cannot allocate memory
    [root@www.654z.com]# service httpd stop
    -bash: fork: Cannot allocate memory
    [root@www.654z.com]# service httpd stop
    -bash: fork: Cannot allocate memory
    [root@www.654z.com]# service httpd stop
    -bash: fork: Cannot allocate memory
    [root@www.654z.com]# top
    -bash: fork: Cannot allocate memory
    [root@www.654z.com]# free
    -bash: fork: Cannot allocate memory

    连free命令都无法执行。reboot也无法执行。怎么办?等待几分钟再试一试。我等了3分钟,然后发现free可以用了。这时候别大意,全部重启一下apache/mysql等,这样就可以稳定一段时间了:


    [root@www.654z.com]# free
                 total       used       free     shared    buffers     cached
    Mem:        524800     245908     278892          0          0          0
    -/+ buffers/cache:     245908     278892
    Swap:            0          0          0
    [root@www.654z.com]# service httpd stop
    Stopping httpd: [  OK  ]
    [root@www.654z.com]# free
                 total       used       free     shared    buffers     cached
    Mem:        524800      81272     443528          0          0          0
    -/+ buffers/cache:      81272     443528
    Swap:            0          0          0
    [root@www.654z.com]# top

    top - 11:27:04 up 11 days,  6:16,  2 users,  load average: 1.53, 0.63, 0.48
    Tasks:  20 total,   1 running,  19 sleeping,   0 stopped,   0 zombie 
    Cpu(s):  6.2%us,  0.6%sy,  0.0%ni, 88.1%id,  5.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Mem:    524800k total,    81656k used,   443144k free,        0k buffers

  •  

  • 点这里复制本页地址发送给您QQ/MSN上的好友
  • 300*300广告