卸载yum并重新安装并配置源
# 查看所有yum组件
rpm -qa | grep yum
#将所有的组件卸载掉
rpm -qa | grep yum | xargs rpm -e --nodeps
#一般下面这三个就行了(太慢可以从http://mirrors.163.com/centos/7/os/x86_64/Packages/ 下载)
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-3.4.3-150.el7.centos.noarch.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
#先安装这个
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
#如下两个有依赖同时安装
rpm -ivh yum-3.4.3-150.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
#配置阿里源参照
https://blog.csdn.net/lovemysea/article/details/79552952