[云服务器] centos8 切换yum 源

八哥 发表于 2023-10-27 04:09:31 | 显示全部楼层 |阅读模式
6540 0
本帖最后由 八哥 于 2023-10-29 12:47 编辑

centOS8的镜像源文件的目录默认都在该路径下:/etc/yum.repos.d/

  1. cd /etc/yum.repos.d/
复制代码

备份原来的yum镜像源

  1. cp /etc/yum.repos.d/CentOS-Linux-BaseOS.repo /etc/yum.repos.d/CentOS-Linux-BaseOS.repo.bak
复制代码

下载国内常用的镜像源并重命名为CentOS-Linux-BaseOS.repo,将其作为当前系统的镜像源

【阿里云镜像站】

如果想使用阿里云镜像,请使用以下命令:

  1. wget -O /etc/yum.repos.d/CentOS-Linux-BaseOS.repo  http://mirrors.aliyun.com/repo/Centos-8.repo
复制代码

【网易镜像站】

如果想使用网易镜像,请使用以下命令:

  1. wget -O /etc/yum.repos.d/CentOS-Linux-BaseOS.repo  http://mirrors.163.com/.help/CentOS8-Base-163.repo
复制代码

添加epel源

安装 epel后,可以通过 yum install package-name安装更多软件。

  1. wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo
复制代码

清理缓存

yum的缓存文件的存放目录是以下路径下:/var/cache/yum 直接清空给目录,或者使用一下命令均可

  1. yum clean all
复制代码

重新生成缓存

  1. yum makecache
复制代码

通过以上操作yum的镜像源就更新完成了。
全部回复(0)
您需要登录后才可以回帖 登录 | 立即注册