1.備份你的原鏡像文件,以免出錯后可以恢復。
cp /etc/yum.repos.d/CentOS-Base.repo{,.backup}
# 或者
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.下載新的CentOS-Base.repo 到/etc/yum.repos.d/
如果 wget 沒有安裝,運行下面命令安裝 wget 軟件。
yum update --skip-broken
yum -y install wget
安裝完成更新下載源
# CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
# CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
# CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3.運行yum makecache生成緩存
yum clean all
yum makecache
參考鏈接:https://github.com/jaywcjlove/handbook/blob/master/CentOS/CentOS7%E6%9B%B4%E6%8D%A2yum%E8%BD%AF%E4%BB%B6%E9%95%9C%E5%83%8F%E6%BA%90.md
https://t.goodrain.com/t/topic/236