centos更改yum源

此处为更改系统yum源为国内的阿里云的镜像地址。方法如下:

1、备份系统yum源以免出错,方便还原:

cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

2、下载CentOS-Base.repo到/etc/yum.repos.d下:

Centos5版本yum源:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

Centos6版本yum源:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
Centos7版本yum源: 
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3、清理并重建缓存:

yum clean all
yum makecache