Symptoms
Websites or webmail can't be reached.
Plesk is not accessible:
Gateway error 502
The following entry can be found in
/var/log/httpd/error_log:Fatal Error Unable to allocate shared memory segment of 134217728 bytes: mmap: Cannot allocate memory (12)
topcommand shows enough RAM on the server, more than was mentioned in the error entry above;sw-engine service cannot start:
# service sw-engine start
Starting sw-engine-fpm: Fri Aug 17 20:40:58 2018 (11150): Fatal Error Unable to allocate shared memory segment of 134217728 bytes: mmap: Cannot allocate memory (12)Container limits checking shows the following:
# cat /proc/user_beancounters | grep shm
shmpages 17604 17604 20480 20480 18
Cause
Container limit shmpages is exceeded by OPcache, which needs more, than segments available.
Resolution
Change OPcache limit
Connect to the server via SSH.
Check current segment size:
# ipcs -lm
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 32768
max total shared memory (kbytes) = 8388608
min seg size (bytes) = 1Go to Tools & Settings > PHP Settings > <PHP version, that has many domains> > php.ini.
Uncomment
opcache.memory_consumptionoption and set it equal to the segment limit (In this case 32) - changes applied automatically to all the domains, that are using this PHP version.
Increase number of segments
Note: If you have access to the Hardware Node, use the resolution below. If not, contact your provider to increase the limit for you.
1.Connect to the server via SSH.
Increase the amount of the corresponding UBC limit for the container to at least 40960:
# vzctl set 10001 --shmpages 40960 --save