错误集----使用yum命令报错(解决)

前言:

我们在yum install xxxx的时候有的时候会因为网络、配置问题导致报错,这里记录下解决的方法~

现象

先上错误代码

[root@localhost yum.repos.d]# yum list
已加载插件:fastestmirror, langpacks
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

解决

以上问题,一般可以通过以下几个方式来解决
① 清理缓存(yum clean all),yum list 重新加载列表
② 查看网卡配置信息是否有误:

[root@localhost yum.repos.d]# vim /etc/sysconfig/network-scripts/ifcfg-eth0(或者根据自己网卡选择ens33)
#查看onboot,如果为no,改为yes,wq保存后重启网卡即可
ONBOOT="yes"

③ 在/etc/resokv.conf中添加nameserver 114.114.114.114或者8.8.8.8,然后ping 114.114.114.114,可以ping 通后,再进行yum clean all ,然后yum list或者yum makecache,最后再次尝试yum install xxx

小结

这里为了凑字数…emmm。。顺带再介绍下114.114.114.114和8.8.8.8的DNS服务器是啥吧~
114.114.114.114和8.8.8.8是常见的DNS地址,8.8.8.8为GOOGLE公司baiDNS地址是全球通独用的,而114.114.114.114是全国通用DNS地址,也是国内第一个开放DNS服务的地址~ 国外的话,还是8比较好,114的话,手机端和电脑端都可以使用,去广告比较牛逼~速度也比较快

你可能感兴趣的:(故障集)