The OOM killer mechanism is a mechanism for Linux to kill processes. If the process corrupts system resources to a certain extent, the OOM killer mechanism will force the process to kill. This article will introduce how Linux uses the OOM killer mechanism.
In simple terms this mechanism will monitor those who take up too much memory, especially in the moment quickly consume large amounts of memory processes, in order to prevent out of memory and the kernel will kill the process.
This function can repeatedly ensure the memory processing even if the memory cannot be released, prevent the system from stalling, and find out the process that consumes excessive memory.
The typical situation is: one machine suddenly ssh remote login, but can ping, indicating that the network is not faulty or the machine is down, it is likely that the sshd process was killed by the OOM killer.
After rebooting the machine, viewing the system log /var/log/messages will reveal an error message similar to Out of Memory: Kill process 247 (sshd).
There is another situation that can lead to ping can not ssh, that is, too many network connections to exhaust the system file descriptor resources, this situation is not considered here.
In the highly available solution using vip, this situation is also prone to brain splitting.
Preventing important system process triggering (OOM) mechanisms from being killed: You can set the parameter /proc/PID/oom_adj to -17 to temporarily turn off the OOM mechanism of the Linux kernel. The kernel will calculate a score for each process by a specific algorithm to determine which process to kill. The oom score for each process can be found in /proc/PID/oom_score.
We think that important processes have sshd, or some monitoring daemons, you can choose the process you want to protect according to your actual situation.
Protecting a process from being killed by the kernel can be done like this:
echo -17 》 /proc/$PID/oom_adj
You can write a simple script to deploy Prevent important processes from being omled on crontab
pgrep -f “/usr/sbin/sshd” |
While read PID;do echo -17 》 /proc/$PID/oom_adj;done
where “/usr/sbin/sshd” can be replaced with a process that you think is important, but be careful not to match Matching is wrong
1. Process selection method
When OOM Killer runs out of memory, it will view all processes and calculate scores for each process. Send the signal to the process with the highest score.
2. Method of calculating scores Previous page12Next page Total 2 pages
Many people dont know what UUCP is doing in Unix. In fact, UUCP is not as complicated as everyone th
Usually when we start the Linux ISO image, we need to burn to the CD first. This wi
UDP is the permanent datagram protocol. It has the same function as the TCP protoco
For the Linux beginners who just started, I still dont know how to configure the ip
What should I do if I want to enter a password every time git is submitted in Ubuntu?
Handling of the Segmentation fault error in Linux programming
How to use Linux to clear Bash environment variables with commands
How to install and use Vsftp in Centos system
How to let ordinary users use port
CentOS batch compression image size operation example
Linux no network installation GCC skills
How does Linux use the OOM killer mechanism?
How to use the vmstat command in Linux
What are the Build 10122 updates? Win10 Build 10122 update at a glance
How to set the number of Win8 tiles?
How to configure Win7 firewall Win7 firewall configuration method
How to set up Win7 system to let Bluetooth listen to songs
Windows 8.1 supports portrait mode. Tablets can be used vertically
How to change (set) computer sleep time in Win7 Ultimate system
Win8 system desktop add computer icon graphic steps
Change the background color and pattern of the Win8 system Metro interface
Win10 Professional Edition shows or hides the detailed tutorial of the folder