阿里云CentOS 8.x系统yum报404的解决方法(Errors during downloading metadata for repository 'appstream'
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
1
2
3
4
5
2
3
4
5
解决方法:针对该问题,阿里云也提供了解决方法,可依次执行如下命令即可解决 该方法只适用于阿里云的ECS服务器,其他IDC公司的服务器可参考教程操作:https://blog.tag.gg/showinfo-3-36185-0.html (opens new window) 1、执行如下命令先将之前的yum文件备份:
rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
1
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
1
2
2
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
1
2
3
2
3
4、运行以下命令重新创建缓存,若没报错,则正常了。
yum clean all && yum makecache
1
注意:若使用阿里云服务器参考本教程重新执行后还有问题,请将 进入 /etc/yum.repos.d/ 目录,将之前下载的yum文件(repo)改名后再重新按照本教程操作一次即可
编辑 (opens new window)
上次更新: 2023/04/09, 16:34:32