Centos 7 yum执行问题

来源:互联网 发布:php中单引号和双引号 编辑:程序博客网 时间:2024/06/15 15:51

今天安装InfluxDB的时候一直无法顺利安装,后来发现yum -y update都无法执行了。

看异常:

[root@iZ8vb8r420ejxfron03cj7Z ~]# sudo yum install influxdbLoaded plugins: fastestmirrorbase                                                                                                                                                                                                                                                   | 3.6 kB  00:00:00     epel                                                                                                                                                                                                                                                   | 4.3 kB  00:00:00     extras                                                                                                                                                                                                                                                 | 3.4 kB  00:00:00     https://packagecloud.io/grafana/stable/el/6/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 302 - FoundTrying other mirror. One of the configured repositories failed (grafana), 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. Disable the repository, 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 grafana     4. 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=grafana.skip_if_unavailable=truefailure: repodata/repomd.xml from grafana: [Errno 256] No more mirrors to try.https://packagecloud.io/grafana/stable/el/6/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 302 - Found

我这里比较有针对性,但是在网上搜了之后总算找到解决方案。
修改/etc/resolv.conf文件,添加nameserver 8.8.8.8,如果是国内的话添加nameserver 114.114.114.114。

执行:

[root@iZ8vb8r420ejxfron03cj7Z yum.repos.d]# cat /etc/resolv.conf #options timeout:1 attempts:1 rotate single-request-reopen#nameserver 114.114.114.114nameserver 8.8.8.8

注意,这里只能保留一个,我要用到的是8.8.8.8的。
之后执行:

service network restart

重试之后一切OK了。