Blog

OpenVZ :: Fix “Unable to fork: Cannot allocate memory”

Tags: memoryopenvzprivvmpages

Published on: July 21, 2014 by Vipin R.N

OpenVZ :: Fix “Unable to fork: Cannot allocate memory”

Scenario:

In OpenVZ management sometimes on accessing a Container from the Node, it says “Unable to fork: Cannot allocate memory“. The VPS id is 273 

# vzctl enter 273

Unable to fork: Cannot allocate memory

Lets see whether its an issue with the Node Memory

# free -m

     total used free shared buffers cached

Mem: 7956 6865 1091 0 145 3106

-/+ buffers/cache: 3614 4342

Swap: 4102 877 3224

 

Its not, so lets go to the proc filesystem entry showing resource control information, which is /proc/user_beancounters file. The Container in question is 273, lets check the file for it :

# cat /proc/user_beancounters | grep 273


Version: 2.5


uid resource held maxheld barrier limit failcnt


273: kmemsize 4605362 4722434 2147483646 2147483646 0


lockedpages 0 0 999999 999999 0


privvmpages 786416 786419 786432 786432 18


shmpages 128 128 262144 262144 0


dummy 0 0 0 0 0


numproc 47 50 999999 999999 0


physpages 76013 76212 0 2147483647 0


vmguarpages 0 0 262144 2147483647 0


oomguarpages 76013 76212 262144 2147483647 0


numtcpsock 9 16 7999992 7999992 0


numflock 5 6 999999 999999 0


numpty 0 0 500000 500000 0


numsiginfo 0 2 999999 999999 0


tcpsndbuf 157536 159864 214748160 396774400 0


tcprcvbuf 180504 477096 214748160 396774400 0


othersockbuf 6984 13736 214748160 396774400 0


dgramrcvbuf 0 8472 214748160 396774400 0


numothersock 11 13 7999992 7999992 0


dcachesize 351186 418905 2147483646 2147483646 0


numfile 930 1037 23999976 23999976 0


dummy 0 0 0 0 0


dummy 0 0 0 0 0


dummy 0 0 0 0 0


numiptent 15 15 999999 999999 0

Check this line

privvmpages 786416 786419 786432 786432 18

 

It means that the memory allocated to this container is exhausted

In order to edit this parameter, the configuration file of the Node has to be edited which is located at /etc/sysconfig/vz-scripts

# vi /etc/sysconfig/vz-scripts/


0.conf 140.conf.destroyed 190.conf 240.conf.destroyed 267.conf ve-263.conf-sample 101.conf 150.conf 200.conf.destroyed 250.conf.destroyed 269.conf.destroyed ve-270.conf-sample 110.conf 160.conf 210.conf 260.conf.bak 270.conf ve-light.conf-sample 120.conf 170.conf 220.conf.destroyed 262.conf 273.conf ve-vps.basic.conf-sample 130.conf 180.conf.destroyed 230.conf 263.conf.destroyed ve-260.conf-sample

The Container in question is 273, so the file we’ve to edit is /etc/sysconfig/vz-scripts/273.conf

# vi /etc/sysconfig/vz-scripts/273.conf
# Copyright (C) 2000-2006 SWsoft. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
ONBOOT=”no”
# UBC parameters (in form of barrier:limit)
# Primary parameters
AVNUMPROC=”40:40″
NUMPROC=”999999:999999″
NUMTCPSOCK=”7999992:7999992″
NUMOTHERSOCK=”7999992:7999992″
VMGUARPAGES=”262144:2147483647″
# Secondary parameters
KMEMSIZE=”2147483646:2147483646″
TCPSNDBUF=”214748160:396774400″
TCPRCVBUF=”214748160:396774400″
OTHERSOCKBUF=”214748160:396774400″
DGRAMRCVBUF=”214748160:396774400″
OOMGUARPAGES=”262144:2147483647″
# Auxiliary parameters
LOCKEDPAGES=”999999:999999″
SHMPAGES=”262144:262144″
PRIVVMPAGES=”786432:786432″
NUMFILE=”23999976:23999976″
NUMFLOCK=”999999:999999″
NUMPTY=”500000:500000″
NUMSIGINFO=”999999:999999″
DCACHESIZE=”2147483646:2147483646″
PHYSPAGES=”0:2147483647″
NUMIPTENT=”999999:999999″
# Disk quota parameters (in form of softlimit:hardlimit)

The Parameter to edit is :
PRIVVMPAGES="786432:786432"
Raise the value, save it and restart the container
#vzctl restart 273Restarting container
Stopping container …
Container was stopped
Container is unmounted
Starting container …
Container is mounted
Adding IP address(es): xx.xx.xx.xx
Setting CPU limit: 400
Setting CPU units: 1000
Setting CPUs: 4
Configure meminfo: 786432
Set hostname: server1.com
File resolv.conf was modified
Setting quota ugidlimit: 10000
Container start in progress…

For more assistance on OpenVZ management, you can contact our OpenVZ Support team

Category : Linux, Troubleshooting, VPS

Vipin R.N

Vipin R.N

Vipin is a no-nonsense, disciplined guy who ensures that everything is carried out with the highest level of perfection. Apart from his great coding skills, he is quite interested in advanced server administration, issue analysis, documentation and training. In-depth knowledge in international politics, ammunition and automobiles makes this hard core Manchester United fan, one of the most referenced personalities in the entire team.

You may also read:

Comments

Add new commentSIGN IN

Let's Connect

Get new updates

Categories

$0.000 items