centos7升级centos8

一、起因是因为某个项目需要在centos8中使用

二、环境准备
centos7.9

注意:
存在数据库的则需要先备份数据库数据。

三、实施
3.1 安装 yum-utils、epel-release、rpmconf 、dnf

yum -y install yum-utils epel-release rpmconf dnf
1
3.2 检查本地环境并清理有影响的rpm包

package-cleanup --problems # 列出有依赖问题的包
package-cleanup --orphans # 列出本机安装在当前仓库不可用的包
package-cleanup --leaves # 列出没有依赖的rpm包
dnf remove yum gcc dracut-network sysvinit-tools -y #更新源后要重新下载的
dnf clean all
rpm -vv --rebuilddb # rpm数据库rebuild,避免一些残留和数据库损坏
1
2
3
4
5
6
3.3 更新yum的仓库

#备份仓库
mkdir /etc/yum.repos.d/bak_el7/ && mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak_el7/
#使用阿里源仓库(https://developer.aliyun.com/mirror/centos)
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
1
2
3
4
3.4 升级系统centos-linux-release

dnf install https://repo.huaweicloud.com/centos-vault/8.5.2111/BaseOS/x86_64/os/Packages/centos-linux-release-8.5-1.2111.el8.noarch.rpm

[root@controller ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
1
2
3
4
5
3.5 删除旧内核

rpm -qa | grep kernel
rpm -e rpm -qa | grep kernel
rpm -vv --rebuilddb
1
2
3
3.6 更新系统使用的包

dnf distro-sync
1
3.7 使用原来的仓库

mv /etc/yum.repos.d/CentOS-Base.repo.rpmsave /etc/yum.repos.d/CentOS-Base.repo
dnf makecache
1
2
3.8 升级系统所有的安装包到el8版本

dnf distro-sync --allowerasing
dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
1
2
3.9 安装之前3.2卸载的安装包和内核

dnf install gcc dracut-network sysvinit-tools vim -y
dnf -y install kernel kernel-core
1
2
3.10 卸载残留的el7的安装包

rpm -qa | grep el7 | xargs dnf remove -y
1
3.11 重启操作系统

reboot
1
四、总结
慎重升级,需要做快照,或将原数据迁移,使用rpm -qa | grep el7检查是否还有el7的包,有的话则需更新成el8。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值