1、備份,為了更新失敗時(shí)切換回去,(我一般不會(huì)做)
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、進(jìn)入yum源配置文件夾
cd /etc/yum.repos.d/
3、根據(jù)centos版本下載對(duì)應(yīng)的新源
CentOS5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
4、yum makecache 生成緩存,會(huì)把新下載CentOS-Base.repo源生效。
更新時(shí)會(huì)報(bào)某個(gè)aliyun timeout,他會(huì)自動(dòng)嘗試阿里其他鏡像,最后自己會(huì)用基礎(chǔ)鏡像,然后自動(dòng)更新一部分。因?yàn)榛A(chǔ)鏡像過時(shí)了。
5、試試更新系統(tǒng) yum -y update
查看系統(tǒng)可用的yum源和所有的yum源
yum repolist enabled