完整报错:
[root@ecs-c6s-large-2-linux-20210526121330 bin]# sudo yum install java CentOS-8 - AppStream 1.4 kB/s | 394 B 00:00 Errors during downloading metadata for repository 'AppStream': - Status code: 404 for https://repo.huaweicloud.com/centos/8/AppStream/x86_64/os/repodata/repomd.xml (IP: 0.0.0.0) Error: Failed to download metadata for repo 'AppStream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
在网上找了很多资料都没用,最后在镜像站找到了原因:
是因为我之前配置阿里云镜像指令错了,以前是这样的:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo1
因此解决方案为:
# 进入yum目录 cd /etc/yum.repos.d # 删除目录下所有文件(注意完整复制,不要漏了那个点) rm -rf ./* # 安装正确的源 wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo # 生成缓存 yum makecache
转载:https://blog.csdn.net/tongkongyu/article/details/122824763