阿里云CentOS 8.x系统yum报404的解决方法(Errors during downloading metadata for repository 'appstream':

2022-03-20 22:45:59
575次阅读
0个评论
2022年1月1日起CentOS官方将不再对CentOS 8提供服务支持,虽然系统可以正常使用,但CentOS 8的yum源已经移除无法使用了,使用yum安装会报错:Repository extras is listed more than once in the configuration CentOS Linux 8 - AppStream Errors during downloading metadata for repository 'appstream':  - Status code: 404 for 完整报错如下:
Repository extras is listed more than once in the configuration
CentOS Linux 8 - AppStream                                                                            18 kB/s | 2.3 kB     00:00    
Errors during downloading metadata for repository 'appstream':
  - Status code: 404 for http://mirrors.cloud.aliyuncs.com/centos/8/AppStream/x86_64/os/repodata/repomd.xml (IP: 100.100.2.148)
Error: Failed to download metadata for repo 'appstream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

解决方法:针对该问题,阿里云也提供了解决方法,可依次执行如下命令即可解决
该方法只适用于阿里云的ECS服务器,其他IDC公司的服务器可参考其他教程操作
1、执行如下命令先将之前的yum文件备份:
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




收藏00

登录 后评论。没有帐号? 注册 一个。