阿里云CentOS8服务器执行yum命令报错404

今天想在阿里云CentOS8服务器上面安装mysql,执行yum命令报错:

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

字面意思看,可以理解为镜像地址已经失效了。搜索一番后,参考阿里云官网https://developer.aliyun.com/mirror/Centos,原因是22年元旦开始,官方停止对CentOS8的维护,需要更换yum镜像源地址。解决方案如下:

  1. 先备份/etc/yum.repos.d/路径下所有.repo文件。
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. centos8官方源已下线,建议切换centos-vault源:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

若未安装wget,则使用curl:

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
  1. 执行yum clean all&&yum makecache,成功后,可以正常执行yum命令了。

你可能感兴趣的:(centos)