CentOS7安装Docker时yum过程报错

!!!离谱

yum install -y yum-utils \
           device-mapper-persistent-data \
           lvm2 --skip-broken

但我直接关机重启之后,再次运行 yum ,全程丝滑…………

1、可能报错1:"Could not resolve host: mirrorlist.centos.org; Unknown error"

Loaded plugins: fastestmirror
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; Unknown error"


 One of the configured repositories failed (Unknown),
 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

2、可能报错2 : Timeout

http://mirrors.ustc.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.ustc.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: (28, 'Resolving timed out after 30560 milliseconds')
Trying other mirror.

3、解决方式

有些帖子说改动 vi /etc/resolv.conf,增加 nameserver 8.8.8.8, 但是这样只是当时好使,等你关机后又不好使了,

  • 网卡的DNS设置是首先生效的/etc/sysconfig/network-scripts/ifcfg-eth0然后才是全局的DNS配置文件 /etc/resolv.conf,其实直接改动/etc/sysconfig/network-scripts/ifcfg-eth0,增加DNS=8.8.8.8,查看 resolv.conf 就会发现已经自动生成了相关的 nameserver。

image

再次尝试yum命令即可,还是超时的话就过一段时间,关机重启再试一下吧,网不好的时候也闹心。

注意:每个人的ifcfg-ens33可能不一样,使用命令ifconfig可以查看
image

posted @ 2023-09-25 18:44  来日可追  阅读(652)  评论(0编辑  收藏  举报