配置网址:
https://developer.aliyun.com/mirror/centos/?spm=a2c6h.25603864.0.0.132666edWNA0GW
1. 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
如果上方的命令不能用请使用下面的三个步骤:
a)切换到本地yum源目录下:
cd /etc/yum.repos.d
b)创建备份目录:
mkdir yum.repos.d.backup
c)移动*.repo到备份目录包:
mv *.repo yum.repos.d.backup
2. 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
上方的是不可以用的,看下方,重要哈!!!重要哈!!!重要哈!!!
centos6(centos6官方源已下线,建议切换centos-vault源)
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
3. 运行 yum makecache 生成缓存
清除缓存
sudo yum clean all
生成新的缓存
sudo yum makecache