CentOS yum有时出现“Could not retrieve mirrorlist ”的解决办法

安装报错如下: 

[root@centos-02 ~]# yum -y install vim lrzsz 
已加载插件: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; 未知的错误"


 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

原因:没有配置resolv.conf

解决方法:

到/etc目录下配置resolv.conf加入nameserver IP,如: 
nameserver 8.8.8.8 
nameserver 8.8.4.4 
search localdomain 
保存再次运行上面的命令就可以。

如果以上方法没解决,可尝试如下方法:

出现此问题,最根本的原因是“/etc/yum.repos.d/epel.repo”里面的镜像源路径不对。

具体步骤如下:
1、打开 /etc/yum.repos.d/epel.repo;
/etc/yum.repos.d/epel.repo

2、注释掉mirrorlist,取消注释baseurl;

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
修改为
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch

3、再次使用yum命令即正常!
yum clean all
yum makecache
yum update

 

### 回答1: 无法检索镜像列表http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock,错误代码为14:curl#6 -“无法解析主机:mirrorlist.centos.org; 未知错误”。 ### 回答2: 当我们在CentOS 7系统中运行yum命令时,有时会遇到“could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7”这样的错误提示。 这个错误的原因可能是由于系统无法连接到CentOS官方的镜像站,导致无法获取到列表。这可能是由于您的网络连接设置错误或者官方镜像站出现了故障所致。 一种解决方法是检查您的网络连接是否设置正确。您可以尝试使用curl命令测试连接是否正常。在终端中输入以下命令: curl http://mirrorlist.centos.org/ 如果您能成功连接到镜像站,则表明连接正常。如果无法连接,则说明可能是网络配置出现了问题,您需要检查您的网络设置。 另一种常见的解决方法是更换CentOS的镜像源。镜像源是用于提供软件包下载的服务器。有时,官方的镜像站可能会出现故障或者速度慢,这时我们需要更换其他的镜像源。 您可以通过编辑yum配置文件来更改镜像源。在终端中输入以下命令进入编辑模式: sudo vi /etc/yum.repos.d/CentOS-Base.repo 然后按下“i”键进入插入模式,将“mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra”这一行注释掉,将“baseurl=http://mirror.centos.org/$contentdir/$releasever/os/$basearch/”这一行的注释符号去掉,并将其修改为您选择的镜像源的地址。例如,如果您选择了清华大学的镜像源,将“baseurl=”http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/”这一行写入配置文件即可。 编辑完成后,按下“ESC”键退出插入模式,然后输入“:wq”命令保存并退出编辑模式。然后再次运行yum命令,如果镜像源配置正确,问题应该就能得到解决。 总的来说,无法检索到CentOS 7中的镜像列表可能是由于网络连接设置不正确或因为官方镜像源故障所导致,您可以通过检查网络连接设置或更改镜像源来解决该问题。 ### 回答3: 当我们在一台CentOS 7服务器上使用yum命令安装或更新软件时,可能会遇到一个错误信息:“could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7”,这是由于yum源配置问题导致的。 yum源是CentOS系统中用于安装软件包的下载服务器,一般情况下,yum源的配置都是自动进行的。但是有时候,由于网络问题或配置错误等原因,yum源无法正确配置,导致出现“could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7”的错误。 解决该问题的方法如下: 1. 检查网络连接:首先,我们需要检查服务器是否连接到互联网。可以使用ping或者traceroute命令来测试网络连接。如果发现网络连接存在问题,可以尝试解决网络连接问题。 2. 检查系统时间:如果我们的服务器时间与NTP服务器不同步,则可能会出现无法连接yum源的问题。因此,我们应该确保系统的时间和NTP服务器的时间同步。 3. 检查yum源文件:yum源配置文件一般在/etc/yum.repos.d目录下。我们可以检查该目录下的所有yum源配置文件,确保它们没有任何错误。也可以使用备份的yum源配置文件替换有问题的配置文件。 4. 更改yum源:可以尝试更改yum源来解决该问题。我们可以从CentOS官网上下载其他yum源,或者从其他镜像站点获取yum源,然后将其添加到yum源配置文件中。更换yum源可以有效解决该问题。 总之,无法检索到yum源的错误是由于yum源配置问题或者网络连接问题导致的。我们可以通过检查网络连接、系统时间、yum源文件或者更改yum源来解决该错误。
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT_狂奔者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值