替换centos的原生yum源为阿里云yum源

      由于centos的原生yum源有时候可能访问速度很慢,下载慢,所以一般可以切换成阿里云的镜像作为yum源,操作如下:

1、备份原生的yum源配置文件

mkdir /etc/yum.repo.d/bak

mv /etc/yum.repo.d/*.repo /etc/yum.repo.d/bak/

2、下载阿里云的yum源配置文件

cd /etc/yum.repo.d/

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

如果提示没有此命令,也可直接在浏览器中访问该URL进行下载,下载完毕后手工上传到/etc/yum.repo.d/路径下

3、生成缓存

yum makecache

至此切换完毕,再次执行yum install命令时就会使用阿里云的yum源了。

 

P.S.

如果使用yum makecache命令报以下错误,那么就是网络有问题,如果服务器能正常访问公网ip,那么则需要检查服务器的DNS配置是否正确,具体可查看下一篇文章。

http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.aliyun.com; Unknown error"

 

posted @ 2020-05-21 16:12  何为实施  阅读(568)  评论(0编辑  收藏  举报