centos7.6 内核升级

一、前言
CentOS 是一款面向服务器的操作系统,所以必须追求极致稳定。这也是官方一直坚持使用旧版内核的原因。

旧版内核虽然非常稳定,但对于一些使用新硬件的服务器来说,兼容性问题简直就是噩梦!

新版内核不但支持新硬件,同时也可以显著的提高系统和网络性能。例如在 4.9 版本及以上的内核均支持全新的 Google BBR TCP 拥塞控制算法。

最新版的内核可以在 kernel.org 上找到。

二、导入新版内核的 yum 源
2.1 导入 elrepo 软件源的 GPG 公钥

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
2.2 导入 elrepo 软件源
说明:该地址可以自动下载该源的最新的软件列表,无需修改地址。

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
三、下载并安装新的内核
3.1 启用软件源并下载安装最新稳定版内核
yum -y --disablerepo=* --enablerepo=elrepo-kernel install kernel-ml
3.2 设定 Grub 默认启动新内核
说明:如果手动修改过 Grub 的配置文件,以下命令可能无法执行成功。请自行修改 Grub 配置文件。

grub2-set-default 0
3.3 使用新的内核重启
reboot
四、检查设置 & 删除旧的内核
4.1 查看当前系统的内核版本号
uname -r
如果输出是 4.10 以上的版本,说明安装成功。

4.13.3-1.el7.elrepo.x86_64
4.2 删除旧内核
说明:删除旧内核的目的是为了防止 yum 更新旧版内核之后覆盖了 grub 默认启动项

yum -y remove kernel kernel-tools
五、后续操作
5.1 更新内核
kernel-ml 不支持使用 yum -y update 直接更新内核。

如果后续需要更新内核,请执行 3.1、3.2 和 3.3。

5.2 卸载旧内核
更新完重启之后,可使用 yum -y remove kernel-ml-<完整的版本号> 来卸载旧内核。

版本号可通过 rpm -qa | grep kernel 获取。

一次升级centos7.6小版本内核

在这里插入图片描述

  1.    yum localinstall kernel-3.10.0-957.10.1.el7.x86_64.rpm  安装内核版本 
    
  2.    grub2-mkconfig -o /boot/grub2/grub.cfg 生成使用新内核的grub文件 
    
  3.    reboot 重启机器 
    
  4.    uname -a 启动后验证内核版本 
    

https://www.cnblogs.com/lideqiang/p/11108766.html
https://zhuanlan.zhihu.com/p/29617407

- [x] 推荐不加载第三方源 +指定版本内核 升级内核https://blog.csdn.net/huoyin/article/details/73835586(指定内核升级)
You can use yum and list all kernel versions that are available (from the enabled repositories at your system) with the following command

###yum list --showduplicates kernel
If the kernel you want is on the list, you can install it directly with yum.

###yum install kernel-<and the version here>
If you want another kernel that is not listed, you can search at Koji download and install with rpm --oldpackage (as indicated at the link you've provided

or you can even try yum.

You have to know that,

It is stronly recommended, always using the latest stable kernel version that Fedora provides.

Last, but not least, you should exclude the kernel updates from yum, through the /etc/yum.conf file.

Append

exclude=kernel
at the end of the file. This should do the trick. That way, yum will not update the kernel(eg 3.14 version) with the latest (eg 3.15) version.

change the default from 1 to 0 to use the new kernel. If you don't change this, the system is still using the old kernel.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## **多内核情况下修改grub启动顺序**:

https://www.cnblogs.com/Wolf-Dreams/p/10947799.html
1.1  进入grub.cfg配置文件存放目录/boot/grub2/并备份grub.cfg配置文件
[root@linux-node1 ~]# cd /boot/grub2/
[root@linux-node1 grub2]# cp -p grub.cfg grub.cfg.bak
[root@linux-node1 grub2]# ls -ld grub.cfg*
-rw-r--r--. 1 root root 5162 Aug 11  2018 grub.cfg
-rw-r--r--  1 root root 5162 Aug 11  2018 grub.cfg.bak

1.2  查看系统当前使用的默认启动项
[root@linux-node1 grub2]# grub2-editenv list
saved_entry=CentOS Linux (3.10.0-862.9.1.el7.x86_64) 7 (Core)

1.3  修改默认启动项并验证
[root@linux-node1 grub2]# cat /boot/grub2/grub.cfg 
[root@linux-node1 grub2]# grub2-set-default "CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)"
[root@linux-node1 grub2]# grub2-editenv list
saved_entry=CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)

1.4  查看/etc/default/grub 配置文件
可以配置grub2启动项的timeout,背景图片等
[root@linux-node1 grub2]# cat /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto biosdevname=0 net.ifnames=0 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

1.5  生成并更新grub.cfg配置文件(编译安装内核是必选,修改启动项顺序可选)
下面的命令会使用/etc/grub.d下的自动配置脚本和/etc/default/grub中定义的变量,自动生成GRUB2配置文件(包括在/boot目录下的内核),
[root@linux-node1 grub2]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-862.9.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.9.1.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-3396984d18374e7d9d83fab36044b7ec
Found initrd image: /boot/initramfs-0-rescue-3396984d18374e7d9d83fab36044b7ec.img
done

1.6  验证默认启动后的内核版本
[root@linux-node1 ~]# uname -r
3.10.0-693.el7.x86_64

注:之前系统默认启动的内核版本为3.10.0-862.9.1.el7.x86_64
1.7  参考文档
http://www.zhongruitech.com/500029444.html
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值