yum update显示Could not resolve host: mirrorlist.centos.org;未知的错误解决办法

搬主题之前有台主机是CentOS的,最近登录主机的SSH,使用yum update命令后出错,直接显示Could not resolve host: mirrorlist.CentOS.org;未知的错误解决办法。这里搬主题研究了一下,给出解决办法给大家参考。

首先提示如下:

[root@Banzhuti]# yum update
已加载插件:copr, fastestmirror, langpacks, product-id, search-disabled-repos
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
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

这下应该如何处理呢?

其实问题的根源是CentOS 7官方已经停止支持了。

问题是mirrorlist.centos.org 这个链接,因为CentOS 7 于 2024-06-30 停止支持后不再存在。所以这个域名自然就找不到。

解决此问题的可能解决方案如下:

  1. 通过 LEAPP 或类似产品迁移到其他项目企业 Linux 产品 8 或 9 的受支持版本。有许多项目和商业产品提供替代品。
  2. 通过提供持续 EL7 支持的几家公司之一寻求长期支持。

或者,你可以打开/etc/yum.repos.d/centos.repo文件,然后注释掉 mirrorlist 行,并输入

[base]
name=CentOS-$releasever - Base
baseurl=https://vault.centos.org/7.9.2009/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
baseurl=https://vault.centos.org/7.9.2009/updates/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://vault.centos.org/7.9.2009/extras/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

最后的效果类似如下:

接下来,再次运行yum update命令,问题解决,不再报错了。

千百度
© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容