清除旧 yum 版本
rpm -qa|grep yum
rpm -qa|grep yum|xargs rpm -e --nodeps
下载安装centos的yum文件
mkdir yum_temp && cd yum_temp
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm --no-check-certificate
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm --no-check-certificate
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --no-check-certificate
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm --no-check-certificate
rpm -ivh *.rpm --force --nodeps
cd .. && rm -rf yum_temp
下载替换centos源
rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# -O指定文件
sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
清缓存
yum clean all
yum makecache
yum list
# 更新软件包(可不操作)(不建议操作,更新后有问题还没解决)
yum update -y