1.查询系统rpm库的yum文件
rpm -qa | grep yum
2.以root用户通过以下命令删除yum文件
rpm -qa | grep yum | xargs rpm -e --nodeps
3.下载相关rpm包
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
4.将rpm包安装到系统中
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm yum-utils-1.1.31-54.el7_8.noarch.rpm --force --nodeps
5.下载阿里镜像到/etc/yum.repos.d目录下
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
6.修改刚下载的文件使用查找替换方式,(:%s/$releasever/7/g),将所有$releasever替换为7
vim /etc/yum.repos.d/CentOS-Base.repo
7.yum clean all
yum makecache
yum update