In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about the kernel upgrade operation of Centos and Ubutun system. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.
In daily operation and maintenance, sometimes the kernel version is too low, resulting in a series of problems, such as cgroup memory leakage when k8s uses 3.10, or some software depends on the kernel version.
1 centos7 upgrade kernel 1.1 check the installed kernel version
Let's install a distribution that contains a specific version of the kernel. To show the installed version of the current system, we can:
# uname-sr Linux 3.10.0-862.el7.x86_64
If we enter https://www.kernel.org/ now, at the time of this writing, we see that the latest kernel version is 5.12 (other versions are available from the same website). Another important thing to consider is the lifecycle of the kernel version-if the version you are currently using is nearing the end of its life cycle, no more bug fixes will be provided after that date. For more information, see the kernel release page.
1.2 upgrade the kernel
Most modern distributions provide a way to upgrade the kernel using package management systems such as yum and officially supported repositories. However, this will only upgrade the kernel to the latest version available in the repository-not the latest version available in https://www.kernel.org/. Unfortunately, Red Hat only allows kernel upgrades using the former. Unlike Red Hat, CentOS allows the use of ELRepo, a third-party repository that can upgrade the kernel to the latest version. The ELRepo repository is a community-based enterprise Linux repository that provides support for RedHat Enterprise (RHEL) and other RHEL-based Linux distributions (CentOS, Scientific, Fedora, etc.). ELRepo focuses on hardware-related software packages, including file system drivers, video card drivers, network drivers, sound card drivers and camera drivers. To enable the ELRepo warehouse on CentOS 7, run:
# Import the public key rpm of the ELRepo repository-- import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org # install the yum source rpm-Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm1.3 of the ELRepo repository to view the available system kernel packages
After the repository is enabled, you can use the following command to list the available kernel-related packages: you can see versions 5.4 and 5.12
Yum-- disablerepo= "*"-- enablerepo= "elrepo-kernel" list available1.4 installs the latest kernel version
For the centos operating system, directly using yum for rpm package installation can avoid some dependency problems, but the latest version of the kernel will be installed by default. If not, you can download the corresponding version from the website, and then specify the version to install, https://buildlogs.centos.org/c7-kernels.x86_64/kernel/.
#-the enablerepo option opens the specified warehouse on the CentOS system. Elrepo is enabled by default, which is replaced by elrepo-kernel. Yum-y-- enablerepo=elrepo-kernel install kernel-ml1.5 sets the default kernel version of GRUB
After the kernel is installed, it needs to be set to the default startup option and restarted before it will take effect.
View all available kernels on the system: # sudo awk-F\'$1kernel = "menuentry" {print iTunes + ":" $2}'/ etc/grub2.cfg 0: CentOS Linux 7 Rescue 8916e15095f33283a3b46d8f9ac7c654 (5.12.1-1.el7.elrepo.x86_64) 1: CentOS Linux (5.12.1-1.el7.elrepo.x86_64) 7 (Core) 2: CentOS Linux (3.10.0-862.el7.x86_64) 7 (Core) 3: CentOS Linux (0-rescue-ea3169a040da42e0b632f72ceb5abd82) 7 (Core) sets the new kernel to the default version of grub2
There are 4 cores on the server, and we will use version 5.12. In order to make the newly installed kernel the default startup option, you can use the grub2-set-default 0 command or edit / etc/default/grub file to set it.
# set GRUB_DEFAULT=0. This means that the first kernel of the GRUB initialization page will generate the grub configuration file as the default kernel grub2-set-default 0 and restart # then run the following command to recreate the kernel configuration # grub2-mkconfig-o / boot/grub2/grub.cfg Generating grub configuration file. Found linux image: / boot/vmlinuz-5.12.1-1.el7.elrepo.x86_64 Found initrd image: / boot/initramfs-5.12.1-1.el7.elrepo.x86_64.img Found linux image: / boot/vmlinuz-3.10.0-862.el7.x86_64 Found initrd image: / boot/initramfs-3.10.0-862.el7.x86_64.img Found linux image: / boot/vmlinuz-0-rescue-8916e15095f33283a3b46d8f9ac7c654 Found initrd image: / boot/initramfs-0-rescue-8916e15095f33283a3b46d8f9ac7c654.img Found linux image: / boot/vmlinuz-0-rescue-ea3169a040da42e0b632f72ceb5abd82 Found initrd image: / boot/initramfs-0-rescue-ea3169a040da42e0b632f72ceb5abd82.img done Verification # reboot # uname-r 5.12.1-1.el7.elrepo.x86_64
Upgraded successfully
Extraneous remarks
No external network, make offline kernel upgrade package
# download yum- y install yum-utils yum- y install createrepo-y repotrack httpd-p. / httpds/ or yumdownloader-- resolve-- destdir / tmp/ansible ansible # to make the latest version of the kernel package Save it in the. / kernel-ml.x86_64/ directory repotrack kernel-ml.x86_64-p. / kernel-ml.x86_64/ or yumdownloader-- resolve-- destdir. / kernel-ml.x86_64 kernel-ml.x86_64 # after it is made, you only need to copy the kernel-ml.x86_64 directory to the machine that needs to be upgraded to delete the old kernel
View all the kernels in the system:
[root@hadoop-iot-test-01 ~] # rpm-qa | grep kernel kernel-headers-3.10.0-957.27.2.el7.x86_64 kernel-tools-3.10.0-862.el7.x86_64 kernel-debug-devel-3.10.0-957.27.2.el7.x86_64 kernel-ml-5.12.1-1.el7.elrepo.x86_64 kernel-3.10.0-862.el7.x86_64 kernel-tools-libs- 3.10.0-862.el7.x86_64
Method 1. Yum remove deletes the RPM package of the old kernel
# yum remove kernel-3.10.0-514.el7.x86_64\ kernel-tools-libs-3.10.0-862.11.6.el7.x86_64\ kernel-tools-3.10.0-862.11.6.el7.x86_64\ kernel-3.10.0-862.11.6.el7.x86_64
Method 2. Yum-utils tool
If no more than three cores are installed, the yum-utils tool will not remove any of them. The old kernel is automatically deleted only if there are more than 3 kernels installed.
# install yum-utils yum install-y yum-utils # remove the old version of package-cleanup-oldkernels2 Ubutun upgrades the kernel 2.1environment
For ubuntu16.04 running on a virtual machine, use the command uname-r to view the current system kernel version 4.15.0-the kernel to be upgraded by 45-generic is 4.20.2
2.2 prepare the required materials
Go to [https://kernel.ubuntu.com/~kernel-ppa/mainline/]] to download the kernel version to be upgraded
Select the corresponding file. Mine is amd64.
Use the command to download (can also be downloaded from the web page)
Wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.20.5/linux-headers-4.20.5-042005_4.20.5-042005.201901260434_all.deb wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.20.5/linux-headers-4.20.5-042005-generic_4.20.5-042005.201901260434_amd64.deb wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.20.5 / linux-image-unsigned-4.20.5-042005-generic_4.20.5-042005.201901260434_amd64.deb wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.20.5/linux-modules-4.20.5-042005-generic_4.20.5-042005.201901260434_amd64.deb2.3 installation
Directly use the dpkg command to install the downloaded deb package
Sudo dpkg-I * .deb
After the installation is complete, restart the ubuntu system and use the command uname-r to check the current version number
# reboot waits for the machine to restart # uname-r Linux hadoop-master02 4.20.5-042005-generic
Kernel upgrade succeeded.
2.4 problems encountered and solutions
* encounter problems
Dependency libssl1.1.0 problem occurred when upgrading the new kernel of ubuntu 16.04
Solution
You need to install the package libssl1.1. If you use the command directly, the installation will fail. You need to add more sources. The update data of this package can only be updated from the officially approved source of ubuntu. Go to the URL to check out [https://packages.ubuntu.com/bionic/libssl1.1]] or download and install a libssl1.1_1.1.0g-2ubuntu4.1_amd64.deb file separately and then dpkg-I * .deb to upgrade.
Wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb dpkg-I libssl1.1_1.1.0g-2ubuntu4_amd64.deb above is what the Centos and Ubutun kernel upgrade operations shared by the editor are like. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.