1、备份
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.backup
2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
如果出现解析错误
Could not resolve host: mirrors.aliyun.com;
解决:添加 DNS 解析即可vi resolv.conf
在里面添加域名解析服务
nameserver 8.8.8.8 nameserver 114.114.114.114
重新拉取试下
3、之后运行yum clean all 清除缓存,运行 yum makecache 生成新的缓存
yum clean allyum makecache