Linux使用CentOS 7内核修改镜像源解决“Could not resolve host: mirrorlist.centos.org;未知的错误“问题

 更新时间:2025年07月17日 17:22:37   作者:努力的雅木茶  
解决yum安装问题需检查网络、备份配置、下载新源、生成缓存及更新源,以恢复正常使用

解决yum安装工具时提示以下错误信息

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 only
 safe 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 working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-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 much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

1、首先确保虚拟机网络畅通

2、备份系统自带yum源配置文件

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.back

3、通过curl下载yum源

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

4、运行yum makecache生成缓存

yum makecache

5、更新yum源,等待完成即可使用yum下载命令

yum -y update

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • Linux信号机制之信号的保存与处理技巧分享

    Linux信号机制之信号的保存与处理技巧分享

    本文旨在为广大Linux学习者提供一份详尽而实用的指南,帮助他们深入理解Linux中的信号机制,掌握信号的保存与处理技巧,我们将从信号的基本概念出发,逐步深入到信号的捕获、保存、处理以及恢复等各个环节,通过生动的实例和详细的解释,让读者能够轻松掌握
    2024-10-10
  • CentOS系统版本检查方法详解

    CentOS系统版本检查方法详解

    在日常的 Linux 系统管理和维护工作中,准确了解操作系统版本信息是一项基础但至关重要的工作,对于使用 CentOS 系统的管理员和开发者来说,掌握多种版本检查方法能够帮助快速诊断问题、确保软件兼容性以及执行正确的系统升级操作,本文给大家介绍了多种检查方法
    2025-08-08
  • Apache Ignite缓存基本操作实例详解

    Apache Ignite缓存基本操作实例详解

    文章介绍了Apache Ignite中IgniteCache的基本操作,涵盖缓存获取、动态创建、销毁、原子及条件更新、异步执行,强调线程池注意事项,避免同步调用导致资源争用或死锁,感兴趣的朋友跟随小编一起看看吧
    2025-07-07
  • 详解CentOS的SVN服务器搭建与自动部署全过程

    详解CentOS的SVN服务器搭建与自动部署全过程

    最近因为工作需要,花了一个晚上时间折腾svn,网上的教程太乱太杂,还有很多是错误的,终于搞定了,所以想着把过程记录下来。这篇文章主要介绍了CentOS的SVN服务器搭建与自动部署全过程,需要的朋友可以参考借鉴,下面来一起看看吧。
    2017-02-02
  • Ubuntu搭建web站点并发布公网访问详细步骤(内网穿透)

    Ubuntu搭建web站点并发布公网访问详细步骤(内网穿透)

    这篇文章主要给大家介绍了关于Ubuntu搭建web站点并发布公网访问(内网穿透)的相关资料,内网穿透是一种实现在外网任意地点访问内网的方法,文中通过代码介绍的非常详细,需要的朋友可以参考下
    2023-12-12
  • Linux之ipmitool管理BMC详解

    Linux之ipmitool管理BMC详解

    这篇文章介绍了ipmitool的基本用法和一些常用的命令,包括获取传感器信息、显示系统信息、电源控制、显示事件日志和启用/禁用BMC用户等,还介绍了如何通过IPMI-over-LAN远程控制BMC,并提供了连接到远程BMC的基本步骤
    2024-11-11
  • 基于Centos7 部署Varnish缓存代理服务器

    基于Centos7 部署Varnish缓存代理服务器

    这篇文章主要介绍了基于Centos7 部署Varnish缓存代理服务器,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-01-01
  • centos8 使用yum 安装 mongodb 4.2的方法

    centos8 使用yum 安装 mongodb 4.2的方法

    这篇文章主要介绍了centos8 使用yum 安装 mongodb 4.2的方法,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下
    2019-10-10
  • Linux判断系统是否发生过异常断电的三种方法

    Linux判断系统是否发生过异常断电的三种方法

    在Linux(Ubuntu)系统中,判断系统是否发生过异常断电(非正常关机),主要有三种方法,其中方法一是最准确的,因为它利用了系统的正常关机标记机制,下面小编为大家详细说说
    2026-02-02
  • linux平台的office文档转pdf的实例(程序员的菜)

    linux平台的office文档转pdf的实例(程序员的菜)

    下面小编就为大家带来一篇linux平台的office文档转pdf的实例(程序员的菜)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-11-11

最新评论