将Centos的默认yum源更换为阿里云源

因为CentOS的默认yum源可能不是国内的源,所以使用yum命令去安装或更新某些东西时会变得很慢。这时候就需要将yum源更换为国内的镜像站点。
这里参考的是这篇博客:

https://blog.csdn.net/inslow/article/details/54177191





将CentOS的yum源改为阿里云镜像源

  1. 备份系统自带的yum源

[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup




2. 下载阿里云的yum源到 /etc/yum.repos.d/

CentOS7

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo


CentOS6

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo


CentOS5

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo




3. 运行yum makecache生成缓存

[root@localhost ~]# yum makecache




4. 看到如下信息就说明yum已经成功更新了!

[root@localhost ~]# yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com





报错

如果你也出现了下图一样的问题,请参考这篇博客

https://www.cnblogs.com/Trees/p/7497268.html

在这里插入图片描述

发布了10 篇原创文章 · 获赞 13 · 访问量 428

猜你喜欢

转载自blog.csdn.net/hufuzhi1146231094/article/details/103788678