前言
CentOS 有个很方便的软件安装工具yum,但是默认安装完CentOS,系统里使用的是国外的CentOS更新源,这就造成了我们使用默认更新源安装或者更新软件时速度很慢的问题,甚至更新失败。
为了使用yum工具能快速的安装更新软件,我们需要将默认的yum更新源配置为国内的更新源。
网上很多教程都是更改yum更新源的配置文件,位于centos目录/etc/yum.repos.d/下,但是需要更改该目录下的CentOS-Base.repo文件好几个地方,看起来麻烦一些。
具体操作
1、备份(针对所有CentOS可用,备份文件在当前路径下)
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者
curl -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
或者
curl -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
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、之后运行yum makecache生成缓存
yum makecache
参考来源
http://mirrors.aliyun.com/help/centos?spm=5176.bbsr150321.0.0.d6ykiD