解决 CentOS 8 镜像无法访问问题(切换至阿里云镜像)
【摘要】 - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
错误:为仓库 'appstream' 下载元数据
有些Linux操作者,在日常运维工作中,会碰到如下问题:
- Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
错误:为仓库 'appstream' 下载元数据失败 : Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
更改为aliyun的仓库
您遇到的错误是由于 CentOS 8 官方镜像列表服务已停止维护导致的。以下是解决方案:
1. 原因说明
自 2022 年 1 月 31 日起,CentOS 官方停止了 CentOS 8 的所有更新和支持,包括镜像服务。因此您无法再通过 mirrorlist.centos.org
获取仓库信息。
2. 解决方案:切换至阿里云镜像源
步骤 1:备份原有仓库文件
sudo mkdir -p /etc/yum.repos.d/backup
sudo mv /etc/yum.repos.d/CentOS-* /etc/yum.repos.d/backup/
步骤 2:下载阿里云 CentOS 8 仓库文件
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
步骤 3:下载阿里云 EPEL 仓库文件(可选)
sudo curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-archive-8.repo
查看/etc/yum.repos.d/目录下的文件
步骤 4:清理并重建缓存b
sudo yum clean all
sudo yum makecache
3. 操作建议
对于生产环境,建议考虑以下替代方案:
-
迁移到 CentOS Stream
-
切换到 Rocky Linux 或 AlmaLinux(RHEL 的社区分支)
-
直接使用阿里云的 Anolis OS(阿里云基于 RHEL 的发行版)
注意事项
-
阿里云镜像仓库是 CentOS 8 的最终版本(8.5.2111)的存档
-
这些仓库不会再有安全更新
-
对于安全敏感的环境,强烈建议升级到受支持的发行版
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)