Failed to download metadata for repo ‘AppStream‘: Cannot download repomd.xml: Cannot download repoda-爱代码爱编程
2021年12月31日CentOS 8 EOL。按照社区规则,CentOS 8的源地址http://mirror.centos.org/centos/8/内容已移除,目前第三方的镜像站中均已移除CentOS 8的源。阿里云的源http://mirrors.cloud.aliyuncs.com和http://mirrors.aliyun.com也无法同步到CentOS 8的源。当您在阿里云上继续使用默认配置的CentOS 8的源会发生报错。
#curl -sSL https://get.daocloud.io/docker | sh
#Executing docker install script, commit: 93d2499759296ac1f9c510605fef85052a2c32be
+ sh -c 'yum install -y -q yum-utils'
错误:Failed to download metadata for repo 'AppStream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
操作步骤
1、运行以下命令备份之前的repo文件
rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
2、运行以下命令下载最新的repo文件
wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo
3、运行以下命令替换repo文件中的链接。
sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo
4、运行以下命令重新创建缓存。
yum clean all && yum makecache
yum源和epel源切换完成后,即可使用yum install命令在实例上安装您所需要的软件包。