centos yum模式简单升级kernel

查看先有的内核

uname -a

然后直接yum升级即可

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

yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm

要是centos8请换8版本的elrepo即可

查看elrepo的ml版本

yum –enablerepo=elrepo-kernel list all | grep kernel-ml

[root@localhost ~]# yum –enablerepo=elrepo-kernel list all | grep kernel

  • elrepo-kernel: hkg.mirror.rackspace.com
    kernel.x86_64 3.10.0-862.el7 @anaconda
    kernel.x86_64 3.10.0-957.27.2.el7 @C7.6.1810-updates
    kernel-headers.x86_64 3.10.0-1160.42.2.el7 @updates
    kernel-ml.x86_64 5.17.1-1.el7.elrepo @elrepo-kernel
    kernel-ml-devel.x86_64 5.17.1-1.el7.elrepo @elrepo-kernel
    kernel-tools.x86_64 3.10.0-957.27.2.el7 @C7.6.1810-updates
    kernel-tools-libs.x86_64 3.10.0-957.27.2.el7 @C7.6.1810-updates
    abrt-addon-kerneloops.x86_64 2.1.11-60.el7.centos base
    kernel.x86_64 3.10.0-1160.59.1.el7 updates
    kernel-abi-whitelists.noarch 3.10.0-1160.59.1.el7 updates
    kernel-debug.x86_64 3.10.0-1160.59.1.el7 updates
    kernel-debug-devel.x86_64 3.10.0-1160.59.1.el7 updates
    kernel-devel.x86_64 3.10.0-1160.59.1.el7 updates
    kernel-doc.noarch 3.10.0-1160.59.1.el7 updates
    kernel-headers.x86_64 3.10.0-1160.59.1.el7 updates
    kernel-lt.x86_64 5.4.188-1.el7.elrepo elrepo-kernel
    kernel-lt-devel.x86_64 5.4.188-1.el7.elrepo elrepo-kernel
    kernel-lt-doc.noarch 5.4.188-1.el7.elrepo elrepo-kernel
    kernel-lt-headers.x86_64 5.4.188-1.el7.elrepo elrepo-kernel
    kernel-lt-tools.x86_64 5.4.188-1.el7.elrepo elrepo-kernel
    kernel-lt-tools-libs.x86_64 5.4.188-1.el7.elrepo elrepo-kernel
    kernel-lt-tools-libs-devel.x86_64 5.4.188-1.el7.elrepo elrepo-kernel
    kernel-ml-doc.noarch 5.17.1-1.el7.elrepo elrepo-kernel
    kernel-ml-headers.x86_64 5.17.1-1.el7.elrepo elrepo-kernel
    kernel-ml-tools.x86_64 5.17.1-1.el7.elrepo elrepo-kernel
    kernel-ml-tools-libs.x86_64 5.17.1-1.el7.elrepo elrepo-kernel
    kernel-ml-tools-libs-devel.x86_64 5.17.1-1.el7.elrepo elrepo-kernel
    kernel-tools.x86_64 3.10.0-1160.59.1.el7 updates
    kernel-tools-libs.x86_64 3.10.0-1160.59.1.el7 updates
    kernel-tools-libs-devel.x86_64 3.10.0-1160.59.1.el7 updates
    libreport-plugin-kerneloops.x86_64 2.1.11-53.el7.centos base
    perf.x86_64 5.17.1-1.el7.elrepo elrepo-kernel
    python-perf.x86_64 5.17.1-1.el7.elrepo elrepo-kernel
    texlive-l3kernel.noarch 2:svn29409.SVN_4469-45.el7 base
    texlive-l3kernel-doc.noarch 2:svn29409.SVN_4469-45.el7 base

安装内核

yum –enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml

安装后查看系统现有的内核

awk -F\’ ‘$1==”menuentry ” {print $2}’ /etc/grub2.cfg

默认是安装好的内核会在第一个

grub2-set-default ‘CentOS Linux (5.17.1-1.el7.elrepo.x86_64) 7 (Core)’

grub2-editenv list

reboot

就好了。

还有一种方式

#vim /etc/default/grub

将GRUB_DEFAULT=saved 改为 GRUB_DEFAULT=0

执行grub2-mkconfig命令来重新创建内核配置

# grub2-mkconfig -o /boot/grub2/grub.cfg

 回滚版本

# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg

查看旧内核(xxxx)的位置为y,例如1

内核回滚操作流程:

# vi /etc/default/grub

将GRUB_DEFAULT=saved 改为 GRUB_DEFAULT=1

执行grub2-mkconfig命令来重新创建内核配置

# grub2-mkconfig -o /boot/grub2/grub.cfg

重启服务器,使内核版本回滚生效

# reboot
# uname –a

异常处理

1. 若出现报错:Found 7 pre-existing rpmdb problem(s), ‘yum check’ output follows:

gssproxy-0.7.0-4.el7.x86_64 is a duplicate with gssproxy-0.4.1-13.el7.x86_64

libnfsidmap-0.25-17.el7.x86_64 is a duplicate with libnfsidmap-0.25-15.el7.x86_64

libtalloc-2.1.9-1.el7.x86_64 is a duplicate with libtalloc-2.1.6-1.el7.x86_64

libtevent-0.9.31-1.el7.x86_64 is a duplicate with libtevent-0.9.28-1.el7.x86_64

libtirpc-0.2.4-0.10.el7.x86_64 is a duplicate with libtirpc-0.2.4-0.8.el7.x86_64

1:nfs-utils-1.3.0-0.48.el7.x86_64 is a duplicate with 1:nfs-utils-1.3.0-0.33.el7_3.x86_64

rpcbind-0.2.0-42.el7.x86_64 is a duplicate with rpcbind-0.2.0-38.el7.x86_64

执行命令:rpm -e #old version

2. 若出现报错: warning:PRMDB altered outside of yum.

执行命令:rm -rf /var/lib/yum/history/*.sqlite

9 Replies to “centos yum模式简单升级kernel”

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注