centos系统中如何将yum的镜像源更换为国内的

以aliyun的镜像为例,aliyun的镜像地址为:http://mirrors.aliyun.com/repo 下载前请选择好系统对应的repo文件

为什么这样做?

墙太高,有时yum无法找到国外源的安装包,导致执行失败。

#进入系统镜像源配置目录

cd /etc/yum.repos.d/

#备份原有的默认配置

mv ./CentOS-Base.repo ./CentOS-Base.repo.back

#获取对应系统版本的repo文件,并替换原默认文件

wget http://mirrors.aliyun.com/repo/Centos-7.repo -O ./CentOS-Base.repo

#清空原有配置

yum clean all

#重新生成源缓存

yum makecache

如果想深入学习,可以查看之前的一篇转载博文:CentOS yum 源的配置与使用