首先备份/etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载对应版本 repo 文件, 放入 /etc/yum.repos.d/ (操作前请做好相应备份)
- CentOS5 :http://mirrors.163.com/.help/CentOS5-Base-163.repo
- CentOS6 :http://mirrors.163.com/.help/CentOS6-Base-163.repo
- CentOS7 :http://mirrors.163.com/.help/CentOS7-Base-163.repo
阿里云 源 http://mirrors.aliyun.com/repo/Centos-8.repo
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
mv CentOS7-Base-163.repo CentOS-Base.repo
运行以下命令生成缓存
yum clean all yum makecache