centos8.5本地yum源报错

在下载文件出现以下错误

centos8.5本地yum源报错_第1张图片

 

[root@server ~]# yum install gcc
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

RHEL8.5-BaseOS                                                                                        0.0  B/s |   0  B     00:00    
Errors during downloading metadata for repository 'BaseOS':
  - Curl error (37): Couldn't read a file:// file for file:///mnt/BaseOS/repodata/repomd.xml [Couldn't open file /mnt/BaseOS/repodata/repomd.xml]
Error: Failed to download metadata for repo 'BaseOS': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

原因:CentOS 8操作系统版本结束了生命周期

解决方案:

1、删除 /etc/yum.repos.d 路径下的本地yum文件,我这里的是base.repo

centos8.5本地yum源报错_第2张图片

2、访问阿里云官网centos镜像_centos下载地址_centos安装教程-阿里巴巴开源镜像站,根据官方步骤,将yum源切换成阿里云的。

1)下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

2)运行 yum makecache 生成缓存

yum makecache

3)CentOS 8 结束生命周期切换源

公网用户:

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

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

yum clean all && yum makecache

阿里云ecs用户:

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

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.aliyuncs.com/repo/Centos-vault-8.5.2111.repo

sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/CentOS-Base.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/CentOS-Base.repo && 
sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/CentOS-Base.repo

yum clean all && yum makecache

3、非阿里云ECS用户会出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影响使用。用户也可自行修改相关配置: eg:

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

 至此安装成功

centos8.5本地yum源报错_第3张图片

你可能感兴趣的:(centos,linux,运维)