引言:最近使用centos的yum源安装依赖时出现了一些问题,同事建议换成国内的阿里的源。
步骤如下
1、备份 (以防万一装拐了)
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
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
3、之后运行yum makecache生成缓存
补充说明:默认的repo文件在/etc/yum.repos.d/目录下,
[root@localhost ~]# cd /etc
[root@localhost etc]# ls | grep yum
yum
yum.conf
yum.repos.d
[root@localhost etc]# cd yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo epel-testing.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo epel.repo
稳妥备份也可以在备份之后下载新源之前用下面的命令,当然也可以省略
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
---------------------------
其他相关资料可移步
(1)http://mirrors.aliyun.com/help/centos?spm=5176.bbsr150321.0.0.d6ykiD
(2)https://yq.aliyun.com/articles/33286