centos8配置阿里云yum源

七海恋空 2022-05-12 浏览(0 评论(0

centos的生命到头了,系统自带的yum源失效了,可以考虑换一下阿里云的yum源。repo文件下载地址为:https://mirrors.aliyun.com/repo/

我的系统版本是centos-8.3.2011,这是centos的过期版本。阿里云没有对应的repo文件,只有Centos-vault-8.5.2111.repo这个文件。没办法,就拿这个文件改造一下吧,改造成Centos-vault-8.3.2011.repo。首先把文件里的版本号都换掉,8.5.2111换成8.3.2011。还有目录也要改一下,参考下面的链接,注意红色字体部分变了。

http://mirrors.aliyun.com/centos-vault/centos/8.3.2011/BaseOS/$basearch/os/

repo文件中每个配置项都提供了3个阿里云镜像下载地址,其实只有第一个是通畅的,其他两个都删掉

 

备份

mv /etc/yum.repos.d/CentOS-Linux-BaseOS.repo /etc/yum.repos.d/CentOS-Linux-BaseOS.repo_bak

复制修改后的repo文件到etc目录

cp /data/software/Centos-vault-8.3.2011.repo /etc/yum.repos.d/CentOS-Linux-BaseOS.repo

清空yum缓存

yum clean all && yum makecache

 

报错提示:

Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

修改CentOS-Linux-AppStream.repo文件中的enabled=0就可以了

vi /etc/yum.repos.d/CentOS-Linux-AppStream.repo