刪除起始的源
cd /etc/yum.repos.d/ && rm -f ./* || echo "delete error"
解除安裝yum
rpm -qa | grep yum | xargs -I {} rpm -e --nodeps {}
下載最新的yum程式的rpm包
如果/etc/yum.repos.d目錄被刪除,需要重新建立該目錄,並進入該目錄
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
安裝yum程式
rpm -ivh *.rpm
匯入證書
rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
新增阿里源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
清理源
yum clean all && yum makecache fast