Нектороые параметры сервера:
RAM 4GB
swap отсутствует
штатное использование памяти < 1GB
root@server
# uname -a
Linux server 2.6.18-194.17.1.el5 #1 SMP Mon Sep 20 07:12:06 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
# rpm -qa | fgrep 'httpd-2'
httpd-2.2.3-43.el5_5.3
# free
total used free shared buffers cached
Mem: 4047628 2537524 1510104 0 418412 1462932
-/+ buffers/cache: 656180 3391448
Swap: 0 0 0
мне понадобятся параметры overcommit_memory и overcommit_ratio:
# man 5 proc
.................
/proc/sys/vm/overcommit_memory
This file contains the kernel virtual memory accounting mode.
Values are:
0: heuristic overcommit (this is the default)
1: always overcommit, never check
2: always check, never overcommit
In mode 0, calls of mmap(2) with MAP_NORESERVE are not checked,
and the default check is very weak, leading to the risk of get‐
ting a process "OOM-killed". Under Linux 2.4 any nonzero value
implies mode 1. In mode 2 (available since Linux 2.6), the
total virtual address space on the system is limited to (SS +
RAM*(r/100)), where SS is the size of the swap space, and RAM is
the size of the physical memory, and r is the contents of the
file /proc/sys/vm/overcommit_ratio.
.........
проверяю параметры
root@server
# sysctl vm.overcommit_memory
vm.overcommit_memory = 0
# sysctl vm.overcommit_ratio
vm.overcommit_ratio = 95
выключаю возможность превышения памяти.
root@server
sysctl vm.overcommit_memory=2
vm.overcommit_memory = 2
и сразу же получаю в error_log апача с интервалом в несколько секунд:
Код: Выделить всё
...
[Wed Dec 08 12:43:29 2010] [error] [client xx.xx.xx.xx] (12)Cannot allocate memory: couldn't create child process: 12: index.cgi
[Wed Dec 08 12:43:29 2010] [error] [client xx.xx.xx.xx] (12)Cannot allocate memory: couldn't spawn child process: /var/www/cgi-local/index.cgi
...Любая программа на сервере запускается через раз ссылаясь на отсутствие свободной памяти.
Все ошибки как бы намекают, что процессы не могут получить память, хотя свободно >3GB, а vm.overcommit_ratio = 95 должно разрешить использование до 3.8GB из 4х (95% от всей памяти).