avatar

升级centos7内核
  1. 查看当前版本

    1
    2
    3
    4
    5
    6
    7
    8
    $ uname -r
    3.10.0-514.el7.x86_64

    $ uname -a
    Linux kube-master 3.10.0-957.el7.x86_64 #1 SMP Wed May 27 12:54:35 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux

    $ cat /etc/redhat-release
    CentOS Linux release 7.6.1810 (Core)
  2. 添加源

    导入ELRepo仓库的公共密钥

    rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

    安装ELRepo仓库的yum源

    rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

  3. 查看可用内核版本

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    [root@kube-master ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
    已加载插件:fastestmirror
    Determining fastest mirrors
    * elrepo-kernel: mirror-hk.koddos.net
    elrepo-kernel | 2.9 kB 00:00:00
    elrepo-kernel/primary_db | 1.9 MB 00:00:11
    可安装的软件包
    elrepo-release.noarch 7.0-4.el7.elrepo elrepo-kernel
    kernel-lt.x86_64 4.4.225-1.el7.elrepo elrepo-kernel
    kernel-lt-devel.x86_64 4.4.225-1.el7.elrepo elrepo-kernel
    kernel-lt-doc.noarch 4.4.225-1.el7.elrepo elrepo-kernel
    kernel-lt-headers.x86_64 4.4.225-1.el7.elrepo elrepo-kernel
    kernel-lt-tools.x86_64 4.4.225-1.el7.elrepo elrepo-kernel
    kernel-lt-tools-libs.x86_64 4.4.225-1.el7.elrepo elrepo-kernel
    kernel-lt-tools-libs-devel.x86_64 4.4.225-1.el7.elrepo elrepo-kernel
    kernel-ml.x86_64 5.6.15-1.el7.elrepo elrepo-kernel
    kernel-ml-devel.x86_64 5.6.15-1.el7.elrepo elrepo-kernel
    kernel-ml-doc.noarch 5.6.15-1.el7.elrepo elrepo-kernel
    kernel-ml-headers.x86_64 5.6.15-1.el7.elrepo elrepo-kernel
    kernel-ml-tools.x86_64 5.6.15-1.el7.elrepo elrepo-kernel
    kernel-ml-tools-libs.x86_64 5.6.15-1.el7.elrepo elrepo-kernel
    kernel-ml-tools-libs-devel.x86_64 5.6.15-1.el7.elrepo elrepo-kernel
    perf.x86_64 5.6.15-1.el7.elrepo elrepo-kernel
    python-perf.x86_64 5.6.15-1.el7.elrepo elrepo-kernel
  4. 升级内核

    yum -y --enablerepo=elrepo-kernel install kernel-ml

  5. 设置grub2

    查看系统上的所有可用内核

    1
    2
    3
    4
    [root@kube-master ~]# sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
    0 : CentOS Linux (5.6.15-1.el7.elrepo.x86_64) 7 (Core)
    1 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
    2 : CentOS Linux (0-rescue-f44735dc8ec740208d9aff79b23edd9e) 7 (Core)

    设置新的内核为grub2的默认版本

    grub2-set-default 0

  6. 验证

    1
    2
    3
    4
    5
    6
    [root@kube-master ~]# uname -a
    Linux kube-master 5.6.15-1.el7.elrepo.x86_64 #1 SMP Wed May 27 12:54:35 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux
    [root@kube-master ~]# uname -r
    5.6.15-1.el7.elrepo.x86_64
    [root@kube-master ~]# cat /etc/redhat-release
    CentOS Linux release 7.6.1810 (Core)