While logging to a VPS from the host server(main node) , you see the message:
Unable to fork: Cannot allocate memory
This usually occurs when VPS is running out of resources especially RAM. Restarting the vps may be a temporary fix which allows you to enter the server . But it prevents executing some commands throwing the same error message .
You can increase privvmpages and kmemsize values for the VPS in order to solve the issue .From the client node in order to see each resource , run the command
cat /proc/user_beancounters
It has five values associated with it: current usage, maximum usage , barrier, limit, and fail counter. The meaning of barrier and limit is parameter-dependent; in short, those can be thought of as a soft limit and a hard limit. If any resource hits the limit, the fail counter for it is increased. This allows the owner to detect problems by monitoring /proc/user_beancounters in the container.
uid resource held maxheld barrier limit failcnt
101: kmemsize 5741113 8347532 2147483646 2147483646 453225323642
privvmpages 33656 44989 98304 98304 106507
In order to increase the value of the two parameters edit the below file from the main node
/etc/sysconfig/vz-scripts/101.conf ( 101 is my vps node)
You can see the value as below
PRIVVMPAGES=”98304:98304″
Increase the value as you need
PRIVVMPAGES=”100000:100000″
Restart your vps after the changes .
# vzctl restart 101
You can also raise the limit as sown below from the host node .
vzctl set 101 –privvmpages 100000:100000 –save
vzctl restart 101
kmemsize
Size of unswappable memory in bytes, allocated by the operating system kernel.
privvmpages
Memory allocation limit. Privvmpages parameter allows controlling the amount of memory allocated by applications.
Tags: logicsupport review, server management, technical support, Unable to fork: Cannot allocate memory, VPS
works for me
[...] can increase the values of these parameters as discussed here [...]
I found lots of interesting information here. The post was professionally written and I feel like the author has extensive knowledge in the subject – Thank yuou!!!
Nice brief and this mail helped me alot in my college assignement. Thank you as your information.
Hey Guys! Just wanted to say hello to the new community
. Thanks for letting me in!