网站首页 > 教程文章 正文
问题背景
CentOS 8 在使用默认软件源时可能会遇到以下错误:
Errors during downloading metadata for repository 'extras':
- Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org
这是因为 CentOS 8 已于 2021 年底结束生命周期(EOL),官方镜像源不再维护。为解决这个问题,我们可以更换为国内稳定的镜像源。
解决方案
以下提供详细的操作步骤:
1. 备份原有配置
首先备份当前系统中的 repo 文件:
cd /etc/yum.repos.d/
mkdir backup
mv *.repo backup/
2. 下载新的源配置
可以选择阿里云源或清华源:
阿里云源:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
清华源:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/repo/centos8/CentOS-Base.repo
3. 修改配置
替换源中的系统版本变量:
sed -i 's/$releasever/8/g' /etc/yum.repos.d/CentOS-Base.repo
4. 重建缓存
dnf clean all
dnf makecache
5. 验证配置
执行系统更新命令验证源是否可用:
dnf update
故障排查
如果遇到 AppStream 数据库问题,可执行:
dnf --disablerepo=* --enablerepo=extras swap centos-linux-repos centos-stream-repos
dnf distro-sync
注意事项
- 选择国内镜像源可以显著提升软件包下载速度
- 阿里云源和清华源都是可靠的选择,可以根据网络情况选择最适合的源
总结
更换国内镜像源是解决 CentOS 8 软件源问题的有效方案,不仅可以解决连接问题,还能提供更快的下载速度。但从长远来看,迁移到持续维护的系统版本是更可靠的选择。
猜你喜欢
- 2024-12-15 [常用工具] cvat安装与使用指北 cvaat
- 2024-12-15 Harbor简介及将私有镜像仓库 Harbor 接入 Containerd 管理介绍
- 2024-12-15 如何制作CentOS 8 Linux安装U盘?UltraISO软件的使用方法介绍
- 2024-12-15 [ 小白玩树莓派系列] 如何在树莓派 4 上USB 外接SSD启动 Android 12L?
- 2024-12-15 Docker的安装与使用 docker的安装方法
- 2024-12-15 独家深度 | 一文看懂 ClickHouse vs Elasticsearch:谁更胜一筹?
- 2024-12-15 5分钟在虚拟机中搭建Linux开发环境
- 2024-12-15 目前还能用的Docker容器加速方案和可用镜像源
- 2024-12-15 容器化之Docker镜像仓库Harbor的安装
- 2024-12-15 kali下对Docker的详细安装 kali安装go
- 最近发表
- 标签列表
-
- location.href (44)
- document.ready (36)
- git checkout -b (34)
- 跃点数 (35)
- 阿里云镜像地址 (33)
- qt qmessagebox (36)
- md5 sha1 (32)
- mybatis plus page (35)
- semaphore 使用详解 (32)
- update from 语句 (32)
- vue @scroll (38)
- 堆栈区别 (33)
- 在线子域名爆破 (32)
- 什么是容器 (33)
- sha1 md5 (33)
- navicat导出数据 (34)
- 阿里云acp考试 (33)
- 阿里云 nacos (34)
- redhat官网下载镜像 (36)
- srs服务器 (33)
- pico开发者 (33)
- https的端口号 (34)
- vscode更改主题 (35)
- 阿里云资源池 (34)
- os.path.join (33)