Centos更换阿里yum源

Centos通过yum来安装软件,默认获取rpm包的软件配置是从国外Centos官方源下载的,因此,安装软件的速度会比较慢,我们在使用时通过会把默认获取rpm包的配置从国外官方源,改成国内的优秀yum源。下面的操作是把阿里的源替换官方源的方法之一。
1、查看yum文件:

 cat /etc/yum.repos.d/CentOS-Base.repo

通过下图的显示可以看出显示的网址都指向Centos官网的源。


2、备份官方源文件,以方便出问题后恢复:

 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

3、从下面链接下载阿里源文件,现在阿里已经不提供CentOS5 yum下载了。

 Centos5阿里源文件:http://mirrors.aliyun.com/repo/Centos-5.repo 
 Centos6阿里源文件:http://mirrors.aliyun.com/repo/Centos-6.repo 
 Centos7阿里源文件:http://mirrors.aliyun.com/repo/Centos-7.repo 

4、载下来将文件改名为:CentOS-Base.repo

5、在服务器找到路径 /etc/yum.repos.d/ 把我们的yum源传至上去覆盖

6、新下yum缓存:

 yum makecache