[Centos系统] CentOS 7.X升级至CentOS 8.2

819 0
Honkers 2025-7-20 08:58:46 来自手机 | 显示全部楼层 |阅读模式

1、安装dnf

CentOS 8开始使用dnf作为包管理器替代yum,参数和yum命令几乎一样,同时安装wget,后面需要单独下载一些 rpm包

  1. [root@localhost yum.repos.d]# yum install -y dnf wget
  2. ...
  3. Installed:
  4. dnf.noarch 0:4.0.9.2-1.el7_6
  5. Dependency Installed:
  6. deltarpm.x86_64 0:3.6-3.el7 dnf-data.noarch 0:4.0.9.2-1.el7_6
  7. libcomps.x86_64 0:0.1.8-14.el7 libdnf.x86_64 0:0.22.5-1.el7_6
  8. libmodulemd.x86_64 0:1.6.3-1.el7 librepo.x86_64 0:1.8.1-7.el7
  9. libreport-filesystem.x86_64 0:2.1.11-53.el7.centos libsolv.x86_64 0:0.6.34-4.el7
  10. python-enum34.noarch 0:1.0.4-1.el7 python2-dnf.noarch 0:4.0.9.2-1.el7_6
  11. python2-hawkey.x86_64 0:0.22.5-1.el7_6 python2-libcomps.x86_64 0:0.1.8-14.el7
  12. python2-libdnf.x86_64 0:0.22.5-1.el7_6
  13. Complete!
复制代码

2、安装CentOS 8发行包

下载CentOS 8的发行包,之所以先下载不直接安装,是因为直接安装有太多依赖,我们需要用–nodeps手动安装,

  1. [root@localhost home]# wget https://mirrors.aliyun.com/centos/8.2.2004/BaseOS/x86_64/os/Packages/centos-release-8.2-2.2004.0.1.el8.x86_64.rpm
  2. [root@localhost home]# ls
  3. centos centos-release-8.2-2.2004.0.1.el8.x86_64.rpm
  4. [root@localhost home]# rpm -Uvh centos-release-8.2-2.2004.0.1.el8.x86_64.rpm --nodeps
  5. warning: centos-release-8.2-2.2004.0.1.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
  6. Preparing... ################################# [100%]
  7. Updating / installing...
  8. 1:centos-release-8.2-2.2004.0.1.el8################################# [ 50%]
  9. Cleaning up / removing...
  10. 2:centos-release-7-6.1810.2.el7.cen################################# [100%]
复制代码

3、添加CentOS 8 base repo

为了下载速度快一点,我们使用阿里云的yum源,

  1. [root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
复制代码

4、安装CentOS 8 EPEL release

  1. [root@localhost yum.repos.d]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
  2. Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
  3. warning: /var/tmp/rpm-tmp.tR2kHM: Header V3 RSA/SHA256 Signature, key ID 2f86d6a1: NOKEY
  4. Preparing... ################################# [100%]
  5. Updating / installing...
  6. 1:epel-release-8-8.el8 ################################# [ 50%]
  7. Cleaning up / removing...
  8. 2:epel-release-7-12 ################################# [100%]
复制代码

5、删除冲突组件

有一些组件在8系列会有冲突,比如内核包,因此我们提前卸载,也可以等你升级时报错,看有哪些有冲突再卸载

  1. rpm -e kernel sysvinit-tools gdbm kexec-tools systemd-sysv yum --nodeps
复制代码

6、开始升级

按照CentOS 8发行版的repo,更新当前系统上组件到对应的CentOS 8版本,耗时会久一点,

  1. [root@localhost home]# dnf --allowerasing distro-sync -y
复制代码

7、安装内核

  1. [root@localhost boot]# dnf -y install kernel
  2. ...
  3. Installed:
  4. kernel-4.18.0-193.14.2.el8_2.x86_64 kernel-core-4.18.0-193.14.2.el8_2.x86_64
  5. kernel-modules-4.18.0-193.14.2.el8_2.x86_64
  6. Complete!
复制代码

8、重启系统

  1. [root@localhost home]# reboot
复制代码

9、查看系统版本和内核

  1. [root@localhost ~]# uname -a
  2. Linux localhost 4.18.0-193.14.2.el8_2.x86_64 #1 SMP Sun Jul 26 03:54:29 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  3. [root@localhost ~]# cat /etc/redhat-release
  4. CentOS Linux release 8.2.2004 (Core)
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行