1. 替换原系统中yum包, 检查初始的yum包有哪些

rpm -qa |grep yum

2. 删除原始的yum包。

yum remove subscription-manager*

yum remove redhat*

yum remove rhn-check

rpm -e Red_Hat_Enterprise_Linux-Release_Notes-7-en-US-7-2.el7.noarch

rpm -qa|grep yum|xargs rpm -e --nodeps

rpm -e redhat-release-server-7.4-18.el7.x86_64 –nodeps

删除redhat-release

rm -rf /usr/share/doc/redhat-release

rm -rf /usr/share/redhat-release

3. 下载163镜像站中CentOS 7下的 yum相关包

wget http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm

wget http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

wget http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm


wget http://repo-cn.cn.prod/repos/CentOS7-20210720/C7-os-x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm

wget http://repo-cn.cn.prod/repos/CentOS7-20210720/C7-os-x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

wget http://repo-cn.cn.prod/repos/CentOS7-20210720/C7-os-x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm

4. 安装下载包

 rpm -ivh yum-* --nodeps

5、下载yum源到/etc/yum.repos.d/

CentOS7-20210120-C7-os-x86_64.repo

CentOS7-20210120-C7-updates-x86_64.repo

CentOS7-20210120-C7-centosplus-x86_64.repo

CentOS7-20210120-C7-extras-x86_64.repo

EPEL7-20201020-epel-7-everything-x86_64.repo

6. 下载镜像站内的镜像源文件

 mv /etc/yum.repos.d /etc/yum.repos.d.backup

 mkdir /etc/yum.repos.d

 cd /etc/yum.repos.d

 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo  

需要把Centos-7.repo文件中的$releasever全部替换为7

在vim中执行:%s/$releasever/7/g快速替换。保存退出

7. 执行 yum clean all,清理之前的缓存

8. 执行 yum makecache,重新生成缓存

9. 执行 yum update升级到CentOS

10、删除centos源

cd /etc/yum.repos.d/

rm -rf CentOS-*

10. 使用非root用户执行sudo bash centos2ol.sh等待升级到Oracle Liunx