Centos內核版本升級

💎關於內核

內核進行的是應用軟件和計算機硬件的交互工做

內核進行的是應用軟件和計算機硬件的交互工做在計算機科學中,內核(英語:kernel)又稱核心,是一個計算機程序,用來管理軟件發出的數據I/O(輸入與輸出)要求,將這些要求轉譯爲數據處理的指令,交由中央處理器(CPU)及計算機中其餘電子組件進行處理,是現代操做系統中最基本的部分。
它是爲衆多應用程序提供對計算機硬件的安全訪問的一部分軟件,這種訪問是有限的,並由內核決定一個程序在何時對某部分硬件操做多長時間。直接對硬件操做是很是複雜的。因此內核一般提供一種硬件抽象的方法,來完成這些操做。經過進程間通訊機制及系統調用,應用進程可間接控制所需的硬件資源(特別是處理器及IO設備)。
linux

一、Centos 6.x系統

1.1 安裝elrepo

yum update -y
# 導入公鑰
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org 
# 安裝6版本的ELRepo
rpm -Uvh elrepo-release-6-8.el6.elrepo.noarch.rpm   
# 安裝新版本內核
yum --enablerepo=elrepo-kernel install kernel-lt -y

目前centos6版本中僅提供有kernel-lt 版本內核,最新內核爲 4.4.17(截至20190121)
https://elrepo.org/linux/kernel/el6/x86_64/RPMS/
image.png
git

1.2 啓用新版本內核

cp /etc/grub.conf{,.bak}
vim /etc/grub.conf
將其中的default修改成0

image.png

1.3 修改完成後重啓服務器

reboot

二、Centos 7.x系統

2.1 安裝elrepo

yum update -y
# 導入公鑰
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org 
# 安裝7.x版本的ELRepo
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
# 安裝新版本內核
yum --enablerepo=elrepo-kernel install kernel-lt -y

目前爲cetnos 7.x提供了ml和lt兩個版本的內核,能夠根據需求進行選擇:
https://elrepo.org/linux/kernel/el7/x86_64/RPMS/
image.png
github

2.2 修改grub文件

Centos7.x 內核升級完畢後,須要修改內核的啓動順序:vim

vim /etc/default/grub

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved      #把這裏的saved改爲0
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0"
GRUB_DISABLE_RECOVERY="true"

接下來還須要運行grub2-mkconfig命令來從新建立內核配置,命令是grub2-mkconfig -o /boot/grub2/grub.cfg,以下:centos

grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.17.171-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-4.17.171-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.2.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.2.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-f0f31005fb5a436d88e3c6cbf54e25aa
Found initrd image: /boot/initramfs-0-rescue-f0f31005fb5a436d88e3c6cbf54e25aa.img
done

2.3 修改完成後重啓服務器

reboot

2.4 關於兩個內核版本的說明

ELRepo有兩種類型的Linux內核包,kernel-lt和kernel-ml。 他們之間有什麼區別?
kernel-ml軟件包是根據Linux Kernel Archives的主線穩定分支提供的源構建的。 內核配置基於默認的RHEL-7配置,並根據須要啓用了添加的功能。 這些軟件包有意命名爲kernel-ml,以避免與RHEL-7內核發生衝突,所以,它們能夠與常規內核一塊兒安裝和更新。
kernel-lt包是從Linux Kernel Archives提供的源代碼構建的,就像kernel-ml軟件包同樣。 不一樣之處在於kernel-lt基於長期支持分支,而kernel-ml基於主線穩定分支。安全

安裝過程當中遇到問題能夠參考 https://dwz.cn/vZotLbZD
bash

三、參考文獻

http://elrepo.org
https://rorschachchan.github.io/2018/08/25/centos6-5升級最新內核4-18的坑/
https://rorschachchan.github.io/2018/06/11/阿里雲centos7升級內核過程/
https://www.admon.org/faqs/kernel-lt-and-kernel-ml/服務器

相關文章
相關標籤/搜索