1、安装dnf
CentOS 8开始使用dnf作为包管理器替代yum,参数和yum命令几乎一样,同时安装wget,后面需要单独下载一些 rpm包
[root@localhost yum.repos.d]# yum install -y dnf wget
...
Installed:
dnf.noarch 0:4.0.9.2-1.el7_6
Dependency Installed:
deltarpm.x86_64 0:3.6-3.el7 dnf-data.noarch 0:4.0.9.2-1.el7_6
libcomps.x86_64 0:0.1.8-14.el7 libdnf.x86_64 0:0.22.5-1.el7_6
libmodulemd.x86_64 0:1.6.3-1.el7 librepo.x86_64 0:1.8.1-7.el7
libreport-filesystem.x86_64 0:2.1.11-53.el7.centos libsolv.x86_64 0:0.6.34-4.el7
python-enum34.noarch 0:1.0.4-1.el7 python2-dnf.noarch 0:4.0.9.2-1.el7_6
python2-hawkey.x86_64 0:0.22.5-1.el7_6 python2-libcomps.x86_64 0:0.1.8-14.el7
python2-libdnf.x86_64 0:0.22.5-1.el7_6
Complete!
2、安装CentOS 8发行包
下载CentOS 8的发行包,之所以先下载不直接安装,是因为直接安装有太多依赖,我们需要用–nodeps手动安装,
[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
[root@localhost home]# ls
centos centos-release-8.2-2.2004.0.1.el8.x86_64.rpm
[root@localhost home]# rpm -Uvh centos-release-8.2-2.2004.0.1.el8.x86_64.rpm --nodeps
warning: centos-release-8.2-2.2004.0.1.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:centos-release-8.2-2.2004.0.1.el8################################# [ 50%]
Cleaning up / removing...
2:centos-release-7-6.1810.2.el7.cen################################# [100%]
3、添加CentOS 8 base repo
为了下载速度快一点,我们使用阿里云的yum源,
[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
[root@localhost yum.repos.d]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
warning: /var/tmp/rpm-tmp.tR2kHM: Header V3 RSA/SHA256 Signature, key ID 2f86d6a1: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:epel-release-8-8.el8 ################################# [ 50%]
Cleaning up / removing...
2:epel-release-7-12 ################################# [100%]
5、删除冲突组件
有一些组件在8系列会有冲突,比如内核包,因此我们提前卸载,也可以等你升级时报错,看有哪些有冲突再卸载
rpm -e kernel sysvinit-tools gdbm kexec-tools systemd-sysv yum --nodeps
6、开始升级
按照CentOS 8发行版的repo,更新当前系统上组件到对应的CentOS 8版本,耗时会久一点,
[root@localhost home]# dnf --allowerasing distro-sync -y
7、安装内核
[root@localhost boot]# dnf -y install kernel
...
Installed:
kernel-4.18.0-193.14.2.el8_2.x86_64 kernel-core-4.18.0-193.14.2.el8_2.x86_64
kernel-modules-4.18.0-193.14.2.el8_2.x86_64
Complete!
8、重启系统
[root@localhost home]# reboot
9、查看系统版本和内核
[root@localhost ~]# uname -a
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
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)