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


在这里插入图片描述

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 04:33:39 PM CST

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
  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值