To overcome this problem, there are several ways / approaches.
Contents
* 1 Panic and automatic reboot
* 2 Setting kernel overcommit
* 3 oom_adj
* 4 References / links
Panic and automatic reboot
We can choose if there OOM condition, automatic kernel panic and reboot it. To do this:
# Echo 1> / proc / sys / vm / panic_on_oom
# Echo 5> / proc / sys / kernel / panic
This means that, within 5 (five) seconds after a kernel panic, direboot automated system. Note: if the kernel or a total hang the machine, of course not automatic reboot. Automatic rebooting could have done if the kernel panic (fatal error) but the kernel is still alive.
To make this setting permanent, add the line:
vm.panic_on_oom = 1
kernel.panic = 5
to / etc / sysctl.conf.
Note: the automatic settings can also be added to the kernel options, namely "panic = N '. In this way we can choose whichever kernel you want to be given this setting and which ones do not. To use the kernel options for autoreboot kernel panic, throw back the line "kernel.panic = 5" from / etc / sysctl.conf and edit / boot / grub / menu.lst and add "panic = 5" in position as below. Note that this menu.lst specific format that will be processed by a script, so the line "kopt =..." after the added "panic = 5" keep dikomen, will be automatically added to each entry is the kernel after we run the script update-grub.
# # # BEGIN AUTOMAGIC kernels LIST
# # Lines between the AUTOMAGIC kernels LIST markers will be modified
# # By the debian update-grub script except for the default options below
# # Uncomment NOT DO THEM, Just edit them to your needs
# # # # Start Default Options # #
# # Default kernel options
# # Default kernel options for automagic boot options
# # If you want special options for specific kernels use kopt_x_y_z
# # Where x.y.z is kernel version. Minor versions can be omitted.
# # E.g. kopt = root = / dev/hda1 ro
# # Kopt_2_6_8 = root = / dev/hdc1 ro
# # Kopt_2_6_8_2_686 = root = / dev/hdc2 ro
# Kopt = root = / dev/hda1 ro panic = 5
Then run update-grub and reboot the kernel.
Setting kernel overcommit
In addition to the first by the panic + autoreboot, we can also set the memory overcommit settings.
# Echo 2> / proc / sys / vm / overcommit_memory
To make this setting permanent, add this line in / etc / sysctl.conf:
vm.overcommit_memory = 2
and reboot the kernel.
This setting prohibits excessive memory allocation by the processes so that the effect of processes not in-kill in OOM conditions but will receive an error message out of memory. For more details, see the Linux kernel documentation in Documentation / vm / overcommit-accounting.
We have a system that uses Spanel 1.2 set using this setting.
oom_adj
Specific processes can be protected from the "massacre" by the OOM by setting:
# Echo -17> / proc /
where is the process ID
Note: the Spanel 1.2, boot script / etc / init.d / ssh has added the following lines like this:
echo -17> / proc / `cat / var / run / sshd.pid` / oom_adj
protecting sshd from OOM killer.
References / links
* Documentation Linux kernel VM subsystem (subdirectory Documentation / vm)
* Search engines with keywords such as:
o oom handling condition on linux
o oom_adj
o oom_pardon (another unofficial patch in Linux to protect the process from the OOM killer; who entered Linux is oom_adj)
o automatic kernel panic reboot
Tidak ada komentar:
Posting Komentar