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

问题: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下载的功能,已经替换了阿里云的源(可百度或者看这个)

之后下载软件还出现无法解析的问题,进行了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 doesnt 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 wont 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源,最后问题解决了。

可以看见下载是成功的了;此为个人实践结果,希望对您有所帮助~

经验分享 程序员 微信小程序 职场和发展