Could not resolve host: mirrorlist.centos.org Centos 7 Unkown error
<h1>问题</h1><p>安装Centos7(core)以后,网卡默认不会启用。这是一个大坑,直接报错,<strong>这是一个过度优化</strong>,有几个开发人员/运维人员安装centos7(core)不用ssh去连接服务器的。</p>
<p>报错如下:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">Loaded plugins: fastestmirror
Could </span><span style="color: rgba(0, 0, 255, 1)">not</span> retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=<span style="color: rgba(0, 0, 0, 1)">stock error was
</span>14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"<span style="color: rgba(0, 0, 0, 1)">
http:</span>//mirror.centos.org/centos/7/os/x86_64/repodata/repomd.xml: curl#6 - "Could not resolve host: mirror.centos.org; Unknown error"<span style="color: rgba(0, 0, 0, 1)">
Trying other mirror</span>.<span style="color: rgba(0, 0, 0, 1)">
One of the configured repositories failed </span>(CentOS-7 - Base),<span style="color: rgba(0, 0, 0, 1)">
and yum doesn't have enough cached data to continue</span>.<span style="color: rgba(0, 0, 0, 1)"> At this point the only
safe thing yum can </span><span style="color: rgba(0, 0, 255, 1)">do</span> is fail. There are a few ways to work "fix"<span style="color: rgba(0, 0, 0, 1)"> this:
</span>1. Contact the upstream <span style="color: rgba(0, 0, 255, 1)">for</span> the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. <span style="color: rgba(0, 0, 255, 1)">for</span> the repository,<span style="color: rgba(0, 0, 0, 1)"> to point to a working
upstream</span>. This is most often useful <span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> you are using a newer
distribution release than is supported by the repository </span>(<span style="color: rgba(0, 0, 0, 1)">and the
packages </span><span style="color: rgba(0, 0, 255, 1)">for</span> the previous distribution release still work).
3. <span style="color: rgba(0, 0, 255, 1)">Run</span> the <span style="color: rgba(0, 0, 255, 1)">command</span><span style="color: rgba(0, 0, 0, 1)"> with the repository temporarily disabled
yum --disablerepo</span>=base ...
4. Disable the repository permanently, so yum won't <span style="color: rgba(0, 0, 255, 1)">use</span> it by default.<span style="color: rgba(0, 0, 0, 1)"> Yum
will </span><span style="color: rgba(0, 0, 255, 1)">then</span><span style="color: rgba(0, 0, 0, 1)"> just ignore the repository until you permanently enable it
again or </span><span style="color: rgba(0, 0, 255, 1)">use</span> --enablerepo <span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> temporary usage:
yum-config-manager --disable base
or
subscription-manager repos --disable</span>=<span style="color: rgba(0, 0, 0, 1)">base
</span>5. Configure the failing repository to be skipped, <span style="color: rgba(0, 0, 255, 1)">if</span> it is unavailable.<span style="color: rgba(0, 0, 0, 1)">
Note that yum will try to contact the repo</span>. <span style="color: rgba(0, 0, 255, 1)">when</span> it runs most commands,<span style="color: rgba(0, 0, 0, 1)">
so will have to try and fail each </span><span style="color: rgba(0, 0, 255, 1)">time</span> (and thus.<span style="color: rgba(0, 0, 0, 1)"> yum will be be much
slower</span>). <span style="color: rgba(0, 0, 255, 1)">If</span> it is a very temporary problem though,<span style="color: rgba(0, 0, 0, 1)"> this is often a nice
compromise:
yum-config-manager --save --setopt</span>=base.skip_if_unavailable=<span style="color: rgba(0, 0, 0, 1)">true
failure: repodata</span>/repomd.xml from base: No more mirrors to try.<span style="color: rgba(0, 0, 0, 1)">
http:</span>//mirror.centos.org/centos/7/os/x86_64/repodata/repomd.xml: curl#6 - "Could not resolve host: mirror.centos.org; Unknown error"<span style="color: rgba(0, 0, 0, 1)">
</span># </pre>
</div>
<h1>解决办法</h1>
<h2>1、故障发生以后,<strong><span style="color: rgba(255, 0, 0, 1)">第一看看网络是否通畅</span></strong></h2>
<div class="cnblogs_code">
<pre>ping www.baidu.<span style="color: rgba(0, 0, 0, 1)">com
</span>#<span style="color: rgba(0, 0, 0, 1)">google dns
ping </span>8.8.8.8 </pre>
</div>
<p>以上均无反应,于是想起来前一段时间设置过一次centos网卡,让他开机自动启动。命令如下</p>
<p>vi /etc/sysconfig/network-scripts/ifcfg-ens33</p>
<p>修改里面的Boot=yes</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">Boot</span>=no (开机引导的时候不启动网卡)
#<span style="color: rgba(255, 0, 0, 1)"><strong>改成yes</strong></span></pre>
</div>
<p>启动网卡</p>
<div class="cnblogs_code">
<pre>ifup ens33</pre>
</div>
<p>查看ip地址</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">ip addr
</span>1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000<span style="color: rgba(0, 0, 0, 1)">
link</span>/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00<span style="color: rgba(0, 0, 0, 1)">
inet </span>127.0.0.1/8<span style="color: rgba(0, 0, 0, 1)"> scope host lo
valid_lft forever preferred_lft forever
inet6 </span><span style="color: rgba(0, 128, 0, 1)">::</span><span style="color: rgba(0, 128, 0, 1)">1/128 scope host</span>
<span style="color: rgba(0, 0, 0, 1)"> valid_lft forever preferred_lft forever
</span>2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000<span style="color: rgba(0, 0, 0, 1)">
link</span>/ether 00:0c:29:63<span style="color: rgba(128, 0, 0, 1)">:c2:ca</span> brd ff<span style="color: rgba(128, 0, 0, 1)">:ff:ff:ff:ff:ff</span><span style="color: rgba(0, 0, 0, 1)">
inet </span>192.168.152.141/24 brd 192.168.152.255<span style="color: rgba(0, 0, 0, 1)"> scope global noprefixroute dynamic ens33
valid_lft 1319sec preferred_lft 1319sec
inet6 fe80</span><span style="color: rgba(0, 128, 0, 1)">::</span><span style="color: rgba(0, 128, 0, 1)">fdb9:c978:ff44:dbc5/64 scope link noprefixroute</span>
valid_lft forever preferred_lft forever</pre>
</div>
<p>虚拟机ip地址是 <span style="color: rgba(255, 0, 0, 1)">192.168.152.141</span></p>
<p> </p>
<h2><span style="color: rgba(255, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1)">2、更新本地缓存:</span></span></h2>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">yum makecache
</span>#<span style="color: rgba(0, 0, 0, 1)"> yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors</span>.cn99.<span style="color: rgba(0, 0, 0, 1)">com
* extras: mirrors</span>.njupt.edu.<span style="color: rgba(0, 0, 0, 1)">cn
* updates: mirrors</span>.cn99.<span style="color: rgba(0, 0, 0, 1)">com
base | </span>3.6 kB00:00:00<span style="color: rgba(0, 0, 0, 1)">
extras | </span>3.4 kB00:00:00<span style="color: rgba(0, 0, 0, 1)">
updates | </span>3.4 kB00:00:00
(1/8): extras/7/x86_64/other_db | 127 kB00:00:00
(2/8): extras/7/x86_64/filelists_db | 246 kB00:00:00
(3/8): updates/7/x86_64/prestodelta | 797 kB00:00:00
(4/8): updates/7/x86_64/other_db | 641 kB00:00:00
(5/8): base/7/x86_64/other_db | 2.6 MB00:00:01
(6/8): base/7/x86_64/filelists_db | 7.1 MB00:00:02
(7/8): updates/7/x86_64/filelists_db | 4.4 MB00:00:03<span style="color: rgba(0, 0, 0, 1)">
extras</span>/7/x86_64/<span style="color: rgba(0, 0, 0, 1)">prestodelta FAILED
http:</span>//mirrors.njupt.edu.cn/centos/7.6.1810/extras/x86_64/repodata/5bfd3d5f07606011226e556e87d978ca1dfe51a63e18d793182900d5bbc702b5-prestodelta.xml.gz: HTTP Error 302<span style="color: rgba(0, 0, 0, 1)"> - Found
Trying other mirror</span>.
(8/8): extras/7/x86_64/prestodelta |65 kB00:00:00<span style="color: rgba(0, 0, 0, 1)">
Metadata </span><span style="color: rgba(0, 0, 255, 1)">Cache</span> Created</pre>
</div>
<p> </p>
</div>
<div id="MySignature" role="contentinfo">
<b>本博客文章绝大多数为原创,少量为转载,代码经过测试验证,如果有疑问直接留言或者私信我。</b> <br> <b>创作文章不容易,</b><span style="color: red">转载文章必须注明文章出处</span><b>;如果这篇文章对您有帮助,点击右侧打赏,支持一下吧。</b><br><br>
来源:https://www.cnblogs.com/passedbylove/p/11105988.html
頁:
[1]