yum安装时出现”Could not retrieve mirrorlist “的解决办法

[root@localhost ~]# yum -y install wget   (注:在下载wget命令并安装)
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=i386&repo=os error was
[Errno 4] IOError: <urlopen error (-3, '\xe5\x9f\x9f\xe5\x90\x8d\xe8\xa7\xa3\xe6\x9e\x90\xe6\x9a\x82\xe6\x97\xb6\xe5\xa4\xb1\xe8\xb4\xa5')>
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
[root@localhost ~]# yum install gcc-c++
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=addons error was
[Errno 4] IOError: <urlopen error (-3, 'Temporary failure in name resolution')>
Error: Cannot find a valid baseurl for repo: addons
 
不管是用上面还是用下面那命令都会出现那错误
原因:没有配置resolv.conf
解决方法:
到/etc目录下配置resolv.conf加入nameserver IP,如:
nameserver 8.8.8.8
nameserver 8.8.4.4
search localdomain
保存再次运行上面命令就可以。
 
=================================

/etc/resolv.conf 配置DNS 客户 

 
/etc/resolv.conf 配置DNS 客户
文件/etc/resolv.conf 配置DNS 客户,它包含了主机的域名搜索顺序和DNS服务器的地址,每一行应包含一个关键字和一个或多个的由空格隔开的参数。
下面是一个例子文件:

nameserver 8.8.8.8
nameserver 8.8.4.4
search localdomain

合法的参数及其意义如下:
nameserver 表明DNS 服务器的IP 地址。可以有很多行的nameserver,每一个带一个I P 地址。在查询时就按nameserver 在本文件中的顺序进行,且只有当第一个nameserver 没有反应时才查询下面的nameserver.
domain 声明主机的域名。很多程序用到它,如邮件系统;当为没有域名的主
机进行DNS 查询时,也要用到。如果没有域名,主机名将被使用,删除所有在第一个点( . )前面的内容。
search 它的多个参数指明域名查询顺序。当要查询没有域名的主机,主机将在由search 声明的域中分别查找。domain 和search 不能共存;如果同时存在,后面出现的将会被使用。
sortlist 允许将得到域名结果进行特定的排序。它的参数为网络/掩码对。允许任意的排列顺序。Red Hat 中没有提供缺省的/ e t c / r e s o l v. c o n f 文件,它的内容是根据在安装时给出的选项动态创建的。

原文链接: https://www.cnblogs.com/BlogNetSpace/p/15188982.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    yum安装时出现"Could not retrieve mirrorlist "的解决办法

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/213235

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月13日 上午1:40
下一篇 2023年2月13日 上午1:41

相关推荐