CentOS 8安装宝塔报错: Cannot prepare internal mirrorlist: No URLs in mirrorlist --解决方法

学习 · 2023-11-16

前几天在CentOS 8安装宝塔报错 Cannot prepare internal mirrorlist: No URLs in mirrorlist
查了下资料:
问题:
在CentOS 8中,使用yum时出现错误,镜像列表中没有url,类似如下:
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

原因
在2022年1月31日,CentOS团队终于从官方镜像中移除CentOS 8的所有包。
CentOS 8已于2021年12月31日寿终正非,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到https://vault.centos.org

解决方法
如果你仍然需要运行CentOS 8,你可以在/etc/yum.repos.d中更新一下源。使用vault.centos.org代替mirror.centos.org。

sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*
sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*

Theme Jasmine by Kent Liao