ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

CentOS7 升级到 CentOS8

2021-11-19 12:58:51  阅读:970  来源: 互联网

标签:升级 centos7 x86 CentOS7 dnf 64 yum root CentOS8


一、升级包

[root@centos7 ~]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

[root@centos7 ~]# yum update 
[root@centos7 ~]# reboot       //升级centos7小版本后需要重启

二、 安装epel-relase、yum-utils和 rpmconf

[root@centos7 ~]# yum install epel-release -y
[root@centos7 ~]# yum install yum-utils -y
[root@centos7 ~]# yum install rpmconf -y

三、升级前检查

1、检查配置:rpmconf -a
执行如下所示,如有选择直接使用缺省设定。

[root@centos7 ~]# rpmconf -a

2、检查叶节点:列出和其他RPM没有依赖的软件包

[root@centos7 ~]# package-cleanup --leaves
Loaded plugins: fastestmirror
libsysfs-2.1.0-16.el7.x86_64
[root@centos7 ~]# 

如果除了 libsysfs 还有其他的包,请执行 yum update,然后重启下

3、检查不再提供的软件包:列出当前仓库中不提供升级的软件包信息

[root@centos7 ~]#  package-cleanup --orphans
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: download.nus.edu.sg
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com

四、安装dnf 并清除yum

1、安装dnf

[root@centos7 ~]# yum install dnf -y 

2、清除yum并升级

[root@centos7 ~]# dnf -y remove yum yum-metadata-parser 
[root@centos7 ~]# rm -Rf /etc/yum
[root@centos7 ~]# dnf upgrade -y

五、使用dnf更新CentOS 8的包

[root@centos7 ~]# dnf -y install https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/Packages/centos-linux-repos-8-3.el8.noarch.rpm https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/Packages/centos-linux-release-8.5-1.2111.el8.noarch.rpm https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-3.el8.noarch.rpm

六、更新epel仓库

[root@centos7 ~]# dnf -y upgrade https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm


### 此时确认版本信息,已经发生了变化
[root@centos7 ~]# cat /etc/centos-release
CentOS Linux release 8.5.2111

七、删除无用文件和CentOS 7的内核并安装CentOS 8的内核

[root@centos7 ~]# dnf clean all   //删除无用的临时文件
[root@centos7 ~]# rpm -e `rpm -q kernel`   //删除CentOS 7的旧核
[root@centos7 ~]# rpm -e --nodeps sysvinit-tools   //确认删除冲突的包

###安装CentOS8内核
[root@centos7 ~]# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync 
 1. 如果报 源重复
	 1. rm -rf /etc/yum.repos.d/*
	 2. curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
 2. Python 3依赖错误
	 1. dnf remove python3
 3. 分段故障
	 1. rm -rf /var/lib/rpm/__db.*
	 2. rpm --rebuilddb
	 3. dnf clean all
	 4. dnf makecache

备注:在安装CentOS8内核的时候报以下错误
在这里插入图片描述

上述问题是由于包依赖问题导致的,系统默认安装的el7版本的,但是内核更新成了el8版本,所以导致依赖出现了问题,解决方法如下:

[root@centos7 ~]# rpm -Va --nofiles --nodigest
Unsatisfied dependencies for initscripts-9.49.53-1.el7_9.1.x86_64:
	sysvinit-tools >= 2.87-5 is needed by (installed) initscripts-9.49.53-1.el7_9.1.x86_64    //initscripts包是el7版本的
Unsatisfied dependencies for iprutils-2.4.17.1-3.el7_7.x86_64:
	/sbin/pidof is needed by (installed) iprutils-2.4.17.1-3.el7_7.x86_64   //iprutils包是el7版本的

[root@centos7 ~]# dnf remove -y initscripts iprutils  //移除上述两个包
[root@centos7 ~]# dnf install -y initscripts iprutils  //重新安装

然后再次执行升级内核的命令即可
[root@centos7 ~]# rm -rf /var/lib/rpm/__db.* 
[root@centos7 ~]# rpm --rebuilddb
[root@centos7 ~]# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync 

此时通过uname -a确认内核状态,仍是3.10.

[root@centos7 ~]# uname -a
Linux centos7 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

八、更新CentOS8的最小化安装的相关package并重启系统

[root@centos7 ~]# dnf -y install kernel-core
[root@centos7 ~]# dnf -y groupupdate "Core" "Minimal Install"
[root@centos7 ~]# reboot

重启之后即可确认内核和版本文件信息均已升至最新

[root@centos7 ~]# uname -a
Linux centos7 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Tue Nov 16 14:42:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

标签:升级,centos7,x86,CentOS7,dnf,64,yum,root,CentOS8
来源: https://blog.csdn.net/m0_37886429/article/details/121419904

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有