搬主题之前有台主机是centos的,最近登录主机的ssh,使用yum update命令后出错,直接显示could not resolve host: mirrorlist.centos.org;未知的错误解决办法。这里搬主题研究了一下,给出解决办法给大家参考。
首先提示如下:
[root@banzhuti]# yum update已加载插件:copr, fastestmirror, langpacks, product-id, search-disabled-reposrepository base is listed more than once in the configurationrepository updates is listed more than once in the configurationrepository extras is listed more than once in the configurationrepository centosplus is listed more than once in the configurationloading mirror speeds from cached hostfilecould not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was14: 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= ... 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 or subscription-manager repos --disable= 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=.skip_if_unavailable=truecannot find a valid baseurl for repo: base/7/x86_64
这下应该如何处理呢?
其实问题的根源是centos 7官方已经停止支持了。
问题是mirrorlist.centos.org 这个链接,因为centos 7 于 2024-06-30 停止支持后不再存在。所以这个域名自然就找不到。
解决此问题的可能尊龙官方平台的解决方案如下:
-
通过 leapp 或类似产品迁移到其他项目企业 linux 产品 8 或 9 的受支持版本。有许多项目和商业产品提供替代品。
-
通过提供持续 el7 支持的几家公司之一寻求长期支持。
或者,你可以打开/etc/yum.repos.d/centos.repo文件,然后注释掉 mirrorlist 行,并输入
[base]name=centos-$releasever - basebaseurl=https://vault.centos.org/7.9.2009/os/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7#released updates [updates]name=centos-$releasever - updatesbaseurl=https://vault.centos.org/7.9.2009/updates/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7#additional packages that may be useful[extras]name=centos-$releasever - extrasbaseurl=https://vault.centos.org/7.9.2009/extras/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7
最后的效果类似如下:
接下来,再次运行yum update命令,问题解决,不再报错了。