@CentOS 7 升级至CentOS 8(linux系统跨版本系统升级)
  3gxxEGAgm6Fj 2023年11月02日 55 0


文章目录


@CentOS 7 升级至CentOS 8(linux系统跨版本系统升级)_xshell

CentOS 7.9升级到CentOS 8.5 解决方案

1.准备一台CentOS 7版本服务器

#查看系统
[root@test ~]# uname
Linux


#查看当前版本
[root@test ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)


#查看版本内核
[root@test ~]# uname -r
3.10.0-693.el7.x86_64

2.准备epel仓库

#安装epel仓库
[root@test ~]# yum install epel-release -y



#安装yum工具(默认为yum工具)
[root@test ~]# yum install yum-utils

3.安装rpmconf软件包

#安装rmp解析配置工具包
[root@test ~]# yum -y install rpmconf



#配置为软件维护的版本,保留rpm默认配置,输入y即可
[root@test ~]# rpmconf -a
Configuration file '/etc/nsswitch.conf'
-rw-r--r--. 1 root root 1938 Apr 28 2021 /etc/nsswitch.conf.rpmnew
-rw-r--r--. 1 root root 1746 Oct 2 2021 /etc/nsswitch.conf
......
...

3.Centos 软件包清理

#清理所有无用软件包
[root@test ~]# package-cleanup --leaves
Loaded plugins: fastestmirror
libsysfs-2.1.0-16.el7.x86_64
zlib-devel-1.2.7-19.el7_9.x86_64

#清理RPM软件包
[root@test ~]# package-cleanup --orphans
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.bfsu.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
.....
...

4.安装Centos 8默认软件管理器dnf

#当前系统中安装dnf软件包管理工具(centos 8默认使用)
[root@test ~]# yum install dnf
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
...
..



#检查确认dnf软件管理工具
[root@test ~]# dnf --version
#出现以下报错(不是dnf安装失败,主要是版本太低,不兼容,需要更新python版本)
Traceback (most recent call last):
File "/usr/bin/dnf", line 57, in <module>
from dnf.cli import main
File "/usr/lib/python2.7/site-packages/dnf/__init__.py", line 30, in <module>
.......
...



#更新dnf管理工具依赖包
[root@test ~]# yum update python*

#为了防止出现别的问题,安装dnf所关联的软件工具
[root@test ~]# yum install dnf-data dnf-plugins-core libdnf-devel libdnf python2-dnf-plugin-migrate dnf-automatic -y




#检查dnf软件管理工具是否正常(以下状态表示dnf就可以正常使用)
[root@test ~]# dnf --version
4.0.9
Installed: dnf-0:4.0.9.2-2.el7_9.noarch at Tue 07 Jun 2022 01:31:12 PM CST
Built : CentOS BuildSystem <http://bugs.centos.org> at Wed 07 Apr 2021 03:52:38 PM CST

Installed: rpm-0:4.11.3-48.el7_9.x86_64 at Tue 07 Jun 2022 01:18:49 PM CST
Built : CentOS BuildSystem <http://bugs.centos.org> at Wed 24 Nov 2021

5.卸载Centos 7默认软件管理器yum

#卸载centos 7中yum软件管理工具(使用dnf卸载 centos 7默认软件管理工具yum)
[root@test ~]# dnf -y remove yum yum-metadata-parser



#删除yum相关配置文件
[root@test ~]# rm -Rf /etc/yum

6.系统更新

#CentOS 7升级到CentOS 8

​【linux下载官方链接】​​​​【centos官方下载】​

#centos 7系统升级(使用新安装的dnf软件管理)
[root@test ~]# dnf upgrade -y

7.系统升级(centos 7升级 centos 8)

#dnf安装CentOS 8发行软件包(基本所有仓库Centos 8软件包均已删除)
[root@test ~]# dnf -y upgrade https://mirrors.bfsu.edu.cn/centos/8-stream/BaseOS/x86_64/os/Packages/centos-stream-release-8.5-3.el8.noarch.rpm

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




#升级epel仓库源
[root@test ~]# dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-8.noarch.rpm

[root@test ~]# dnf -y upgrade https://mirrors.bfsu.edu.cn/epel/epel-release-latest-8.noarch.rpm



#清空所有缓存
[root@test ~]# dnf clean all




#删除 centos 7内核包
[root@test ~]# rpm -e `rpm -q kernel`



#出现报错(一般为软件包不兼容或者软件包冲突导致,可根据以下方式卸载即可)
#卸载冲突的软件包
[root@test ~]# rpm -e --nodeps sysvinit-tools




#启动CentOS 8系统升级
[root@test ~]# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync






#安装适用的centos 8内核
[root@test ~]# dnf -y install kernel-core




#min化安装centos 8软件包
[root@test ~]# dnf -y groupupdate "Core" "Minimal Install"
#出现错误(centos8.0 软件仓库报错)

#删除原来的阿里软件仓库
[root@test ~]# rm -rf /etc/yum.repos.d/CentOS-Base.repo
#下载华为centos8版本的软件仓库
[root@test ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-8-reg.repo



#清理仓库缓存
[root@test ~]# dnf clean all
#重新生成缓存并查看仓库(确认仓库是否正常)
[root@test ~]# dnf repolist


#仓库修改完成后,继续安装min
[root@test ~]# dnf groupupdate "Core" "Minimal Install" --allowerasing

[root@test ~]# dnf groupupdate "Core" "Minimal Install" --skip-broken
[root@test ~]# rpm -Va --nofiles --nodigest
[root@test ~]# rpm --rebuilddb
[root@test ~]# dnf clean packages





#查看当前的系统版本(已经升级为centos 8.5)
[root@test ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111

8.升级后系统测试

#安装nginx(安装成功表示升级没有问题)
[root@test ~]# dnf install nginx


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  9E2BTpjt8nym   2023年12月06日   35   0   0 WindowsgitCentOS
3gxxEGAgm6Fj