在下载文件出现以下错误
[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
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
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
至此安装成功
如果下载速度过慢,访问阿里云容器镜像服务->镜像工具->镜像加速器,进行里面的配置(阿里云登录 - 欢迎登录阿里云,安全稳定的云计算服务平台)
如果出现报错Failed to restart docker.service: Unit docker.service not found. 这是因为输入docker命令会自动将docker变成podman,所以需要用systemctl restart podman命令