当前位置: 首页 > news >正文

Yum使用时报错

已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"One of the configured repositories failed (未知),and yum doesn't have enough cached data to continue. At this point the onlysafe thing yum can do is fail. There are a few ways to work "fix" this:1. Contact the upstream for the repository and get them to fix the problem.2. Reconfigure the baseurl/etc. for the repository, to point to a workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=<repoid> ...4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable <repoid>orsubscription-manager repos --disable=<repoid>5. Configure the failing repository to be skipped, if it is unavailable.Note that yum will try to contact the repo. when it runs most commands,so will have to try and fail each time (and thus. yum will be be muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=trueCannot find a valid baseurl for repo: base/7/x86_64

这个错误表明您下载的 CentOS-Base.repo 文件内容不是有效的 Yum 仓库配置文件,而是一个 HTML 网页(可能是错误页面或跳转页面)。

问题原因:

您使用的下载链接 https://mirrors.aliyun.com/repo/Centos-vault-7.9.2009.repo 可能已经失效或不再提供直接的文件下载,而是返回了一个 HTML 页面。

解决方案
请按照以下步骤手动创建正确的仓库配置文件:

删除无效的配置文件

rm -f /etc/yum.repos.d/CentOS-Base.repo

直接手动创建配置文件
使用 vi 或 nano 编辑器创建新文件:

vi /etc/yum.repos.d/CentOS-Base.repo

将以下内容复制粘贴到文件中
这里提供阿里云和清华大学两个源的配置,您可以选择其中一个:

选项 A:阿里云 CentOS-Vault 源

ini

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

选项 B:清华大学 CentOS-Vault 源

ini

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

保存并退出编辑器

在 vi 中:按 Esc 键,然后输入 :wq,按回车。

在 nano 中:按 Ctrl+X,然后按 Y 确认保存,再按回车确认文件名。

清理缓存并重新生成

yum clean all
yum makecache

现在测试 Yum 是否正常工作

yum update

解释
我们手动创建了一个配置文件,直接指定了 baseurl(具体的镜像地址),而不是使用 mirrorlist(需要动态解析的镜像列表),这样就绕过了 DNS 解析问题。

由于 CentOS 7 已经停止维护,我们使用了 7.9.2009 这个最终版本的归档目录(vault),这些地址是稳定的,不会变动。

选择阿里云或清华大学的镜像源通常在国内访问速度较快。

完成以上步骤后,您的 Yum 应该就能正常工作了。如果还有其他仓库(如 epel)出现问题,也需要对 /etc/yum.repos.d/ 目录下的其他 .repo 文件进行类似的处理。

http://www.dtcms.com/a/340048.html

相关文章:

  • Spring Boot 全局异常处理
  • 快速了解Anaconda系统
  • 08.5【C++ 初阶】实现一个相对完整的日期类--附带源码
  • implement libtime on Windows
  • MyCAT基础概念
  • Python函数总结
  • week2-[一维数组]最大元素
  • 单细胞格式转换 rds 转成 h5ad
  • transformer模型初理解
  • Transformer、BERT、BEiT等模型相关八股及代码【自用】
  • HJ4 字符串分隔
  • 神经网络训练过程详解
  • 电流采样实现方法
  • JavaScript 代码保护与混淆
  • Vue2+Vue3前端开发_Day1
  • 端口映射原理操作详解教程:实现外网访问内网服务,本地路由器端口映射公网ip和软件端口映射域名2种方法
  • Qwen2.5-vl源码解读系列:LLM的Embedding层
  • MySQL常用函数
  • 首届机器人足球运动会技术复盘:从赛场表现看智能机器人核心技术突破
  • Wireshark获取数据传输的码元速率
  • 中科米堆CASAIM提供机加工件来料自动化测量尺寸方案
  • Origin绘制气泡图|科研论文图表教程(附数据格式模板)
  • 【HarmonyOS】H5 实现在浏览器中正常跳转 AppLinking 至应用
  • Java基础 8.19
  • 基于SpringBoot的停车场管理系统【2026最新】
  • C文件/Linux内核级文件理解
  • 软考网工选择题-1
  • 路由器详解
  • Windows 8.1 补丁 KB2919355 安装方法 详细步骤
  • 【Netty4核心原理⑫】【异步处理双子星 Future 与 Promise】