Tip: Enable the Linux server to automatically restart the kernel panic.

Source: Internet
Author: User

Linux is much more mature than it was a few years ago, but sometimes there will still be an inexplicable and undefinable kernel panic situation. For most Linux users, restart the kernel panic, however, for system administrators and hosting service providers who are engaged in virtual hosts, shared hosts, and OpenVZ VPS hosts, unknown kernel panic may not be very friendly if the system fails, if there is no KVM over IP address, the hosting service provider needs to report to the independent server provider at the upper level first, for example, submitting a ticket request or making a phone call, then the independent server supplier needs time to verify your data, process your ticket, and finally to the real data center. Generally, during the daytime in China at night, only a few persons are on duty in the data center, it may have been more than 20 minutes since you finally restarted ticket. During this 20-minute downtime, you have to write a letter to your own customers to explain the situation, the problem is that this 20 minutes is still the ideal situation. If you encounter a very bad independent server provider or data center, ticket processing should be measured in hours or days, or if you are One man, sleeping at night, does not receive a kernel panic alarm, so it takes more time. Is there a way to enable the Linux server to automatically restart the kernel panic? VPSee describes a simple and effective tips:

Edit the/etc/sysctl. conf file and define to automatically restart Linux after 20 seconds of kernel panic:

# vi /etc/sysctl.confkernel.panic = 20

How amazing is Linux? Can I restart the kernel panic automatically if it doesn't work? Let's take a look at how this part of the code works in the Linux kernel. The most authoritative information is always from the kernel source code:

# Vi linux-2.6.31.8/kernel/panic. c

 
 
  1. ...  
  2.  if (panic_timeout > 0) {  
  3.                 /*  
  4.                  * Delay timeout seconds before rebooting the machine.  
  5.                  * We can't use the "normal" timers since we just panicked.  
  6.                  */ 
  7.                 printk(KERN_EMERG "Rebooting in %d seconds..", panic_timeout);  
  8.  
  9.                 for (i = 0; i < panic_timeout*1000; ) {  
  10.                         touch_nmi_watchdog();  
  11.                         i += panic_blink(i);  
  12.                         mdelay(1);  
  13.                         i++;  
  14.                 }  
  15.                 /*  
  16.                  * This will not be a clean reboot, with everything  
  17.                  * shutting down.  But if there is a chance of  
  18.                  * rebooting the system it will be rebooted.  
  19.                  */ 
  20.                 emergency_restart();  
  21.         }  
  22. ...  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.