侧边栏壁纸
博主头像
张种恩的技术小栈博主等级

行动起来,活在当下

  • 累计撰写 748 篇文章
  • 累计创建 65 个标签
  • 累计收到 39 条评论

目 录CONTENT

文章目录

CentOS使用国内yum镜像源

zze
zze
2019-10-29 / 0 评论 / 0 点赞 / 625 阅读 / 2309 字

不定期更新相关视频,抖音点击左上角加号后扫一扫右方侧边栏二维码关注我~正在更新《Shell其实很简单》系列

有时候 CentOS 默认的 yum 源不一定是国内镜像,导致 yum 在线安装及更新速度不是很理想。这时候需要将 yum 源设置为国内镜像站点。
国内主要开源的开源镜像站点应该是网易和阿里云了,下面以修改 yum 镜像源为网易镜像源为例。

备份原有yum配置文件

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

替换配置文件

进入yum源配置文件目录 /etc/yum.repos.d,下载网易源配置文件:

cd /etc/yum.repos.d
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

这里我是以 CentOS 7 为例,如果你的版本不同,则修改对应地址即可,CentOS 各版本对应源配置文件地址如下:

生成缓存

先清理原来的 yum 源缓存:

yum clean all

重新生成缓存:

yum makecache

测试

查看 yum 仓库源名称确认仓库源是否已经切换到网易源~

[root@localhost ~]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
源标识                        源名称                                    状态
!base/7/x86_64                CentOS-7 - Base - 163.com                 10,097
!extras/7/x86_64              CentOS-7 - Extras - 163.com                  305
!updates/7/x86_64             CentOS-7 - Updates - 163.com                 685
repolist: 11,087

epel源安装

安装阿里云 epel 源:

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
0

评论区