1、查看当前源
yum repolist
2、备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
3、下载新的CentOS-Base.repo 到/etc/yum.repos.d/,若无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
4、之后运行yum makecache生成缓存
有时候yum可能卡住假死,yum clean all 提示卡住进程号,杀掉重新来即可