Quantcast
Channel: System Administration News » systems administrator
Viewing all articles
Browse latest Browse all 5

Prevent memory overrun on a Linux server

$
0
0

Default Linux has a complex mechanism called OOM-Killer (for Out-Of-Memory Killer), it is incorporated into the Linux kernel and allow for exceeding memory and kill unnecessary processes to avoid a complete server crash. OOM-Killer will be called when the RAM and SWAP are fully utilized and the system has enough memory to allocate to the process. Then OOM-Killer determines which process to kill automatically.

linux-oom

To find all the processes killed by OOM-Killer we can use the following command:
grep oom-killer / var / log / messages
Here we see that OOM-Killer ended httpd process (or Apache). In some cases, for example when using a motor database containing many records, or OOM-Killer tends to complete the SSH process, database, web server, it will be useful to modify the behavior of Linux with the available memory.

For this we modify the kernel parameter overcommit_memory, this parameter can take three different values:

0: This is the default behavior, the memory reservations will be accepted or rejected.
1: Always accept
2: Accept requests, if it does not exceed the amount specified in the resource parameter overcommit_ratio

The overcommit_ratio parameter (default 50) determines the percentage of physical memory that is allowed to allocate more swap. To know the amount of memory that is allowed to allocate, the calculation is as follows: SWAP ((* overcommit_ratio RAM) / 100)

To avoid memory overrun, we’ll change the settings by putting two cores overcommit_memory overcommit_ratio 2 and 95 (Some argue for lower values such as 75 or 85). The operations must be performed as root.

To temporarily change (canceled at the next reboot):
echo 2> / proc / sys / vm / overcommit_memory
echo 95> / proc / sys / vm / overcommit_ratio

For a permanent change, edit the file / etc / sysctl.conf
vi / etc / sysctl.conf

And add / edit the following lines:
vm.overcommit_memory = 2
vm.overcommit_ratio = 95


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images