Centos 7 K8S环境 yum install时报错解决办法-实用

在公司有限制的虚拟机环境中,由于DNS服务器无法解析download.docker.com,导致yum安装时出错。已尝试更换为阿里云源但问题依旧。解决方案包括禁用或跳过问题仓库,以及配置yum在仓库不可用时跳过。执行相应yum命令后,问题得到解决,能够成功下载所需软件。
摘要由CSDN通过智能技术生成

问题:Centos 7 K8S环境 yum install时报错,“Could not resolve host: download.docker.com; Unknown error”
Trying other mirror.的解决办法

背景:公司虚拟机资源做了限制导致配置DNS server为114.114.114.114或者8.8.8.8都不可以解析,修改地址为自建DNS解决。

但是目前还需要具备可以yum下载的功能,已经替换了阿里云的源(可百度或者看这个centos7 keepalived+高可用服务搭建-主机yum源更改

之后下载软件还出现无法解析的问题,进行了yum源的替换还是不行,怀疑是做了限制。之后根据报错如下命令行所示

[root@master1 service]# yum install -y dig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
https://download.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: download.docker.com; Unknown error"
Trying other mirror.


 One of the configured repositories failed (Docker CE Stable - x86_64),
 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=docker-ce-stable ...

     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 docker-ce-stable
        or
            subscription-manager repos --disable=docker-ce-stable

     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=docker-ce-stable.skip_if_unavailable=true

failure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try.
https://download.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: download.docker.com; Unknown error"

转义如下:

其中一个配置的存储库失败(Docker CE Stable - x86_64),
yum没有足够的缓存数据来继续。在这一点上唯一
yum能做的最保险的事就是失败。有几种方法可以“解决”这个问题:

  1. 联系源仓库,让他们解决问题。(不现实)

  2. 重新配置baseurl/etc。对于存储库,指向一个工作的上游。如果您使用的是更新的
    发行版比存储库(和以前发行版的包仍然可以工作)。

3.在暂时禁用存储库的情况下运行该命令

 yum --disablerepo=docker-ce-stable

4.永久禁用存储库,这样yum在默认情况下就不会使用它。yum然后会忽略存储库直到永久启用它
再次使用——enablerepo作为临时使用:

 yum-config-manager --disable docker-ce-stable
        or
 subscription-manager repos --disable=docker-ce-stable
  1. 如果失败的存储库不可用,则将其配置为跳过。
    请注意,yum将尝试联系repo。当它运行大多数命令时,每次都要尝试失败。Yum将会变得很慢)。如果这是一个暂时的问题,这通常是一个很好的妥协:
 yum-config-manager --save --setopt=docker-ce-stable.skip_if_unavailable=true

将3、4、5的命令复制执行下,逻辑应该类似于刷新docker、k8s的yum源,最后问题解决了。

可以看见下载是成功的了;此为个人实践结果,希望对您有所帮助~
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值