The company did a wait-for-guarantee 3 evaluation, and found that there were vulnerabilities in the kernel during system vulnerability detection and needed to be upgraded.
Name | Version |
---|---|
Kernel before upgrade | CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core) |
Kernel after upgrade | CentOS Linux (3.10.0-957.1.3.el7.x86_64) 7 (Core) |
The upgrade method is very simple. Find the kernel rpm package of the corresponding version, and then directly use yum or rpm to install it. In this process, you may need to deal with some dependencies between packages.
$ yum install -y kernel-3.10.0-957.1.3.el7.x86_64.rpm kernel-headers-3.10.0-957.el7.x86_64.rpm kernel-tools-3.10.0-957.1.3.el7.x86_64.rpm kernel-tools-libs-3.10.0-957.1.3.el7.x86_64.rpm
After installing the new version of the kernel, you must do the following, otherwise you will step on the pit when restarting the server like me.
**The purpose of the next operation is to change the version of the kernel loaded when the server starts up through grub! **
View the currently installed system kernel
$ rpm -qa kernel* kernel-3.10.0-957.1.3.el7.x86_64 kernel-headers-3.10.0-957.el7.x86_64 kernel-tools-3.10.0-957.1.3.el7.x86_64 kernel-tools-libs-3.10.0-957.1.3.el7.x86_64
Check the default kernel version of the current system, the results may be as follows:
$ grub2-editenv list # Result 1: No relevant information saved_entry=0 # Result 2: The currently running system version saved_entry=CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)
Switch the default kernel version when the system starts:
$ grub2-set-default 'CentOS Linux (3.10.0-957.1.3.el7.x86_64) 7 (Core)'
Then you can restart the server smoothly, and check the system information after restarting:
$ uname -a or $ cat /proc/version Linux version 3.10.0-957.1.3.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36 ) (GCC)) #1 SMP Thu Nov 29 14:49:43 UTC 2018
The kernel upgrade is now complete.
Since there is a correct operation process, sometimes it is often accidental to make some mistakes. Because it was the first time I did a kernel upgrade, I stepped on the hole smoothly. Please look down for the exciting process:
After the new version of the kernel is installed, the server needs to be restarted to take effect. The first operation is handled as an ordinary rpm package upgrade. After the installation is complete, init 6
will be executed to restart the server. The result is sad, as shown below:
I stuck here and didn’t move. I didn’t report an error after seeing the prompt. I just press Enter. As a result, the following scene appears:
Cannot find the corresponding version of the kernel! ! !
WTF!!!
After careful analysis, the prompt message says that the "3.10.0-327.el7.x86_64" version of the kernel cannot be found. In that case, let Baidu (google)! Keywords "centos 7 kernel upgrade and restart can not find the kernel", find the following articles:
After reading the first and second documents, I probably understand the principle of repair, that is, modify the kernel boot sequence. The reinstallation of the original system kernel in the first article is of little significance to this kernel upgrade, but the second is a reminder I am a core-everything in the linux system is a file!
Since it is possible to change the kernel boot sequence through the grub command line before the server crashes, you can definitely enter the grub modification or other methods through the rescue mode after the crash.
Because it was the first time I encountered this kind of problem, I had a virtual machine on hand, so I reproduced the error scene with the mentality of trying it out, restarted the virtual machine and came to the kernel selection interface:
Tip: "e" edit the currently selected item! Anyway, it is the virtual machine, just do it casually, and enter the editing state decisively:
The kernel information just appeared, and I was so happy, why not try to change the system version information here, and then continue to read:
Just change it all in one go, and the big deal is to reinstall the system (provided that the current server does not deploy particularly important services, otherwise you still have to be more rigorous). Change the information in the red box in the picture above to the new version "3.10.0-957.1.3.el7.x86_64", and then Ctrl-x to enter the system loading interface, instantly feeling relieved.
Wait for the system startup to complete, log in and check the status, everything is normal! ! !
Real knowledge from practice! ! ! (PS: It's okay, don't mess around, you must study hard before doing it!!!)
Post a document with B! ! !
( adsbygoogle = window.adsbygoogle || []).push({});
Recommended Posts