docker安装 Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&i
·
docker安装出现一下问题解决方法
[root@vbox ~]# yum install -y yum-utils \
> device-mapper-persistent-data \
> lvm2 --skip-broken
已加载插件: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
一、检查网络
-
检查网络连接 在终端中执行
ping www.baidu.com。
若能通:说明网络连接正常,请继续下一步排查。
若不通:说明网络配置有问题,需要先解决基础网络连通性,例如重启网络服务systemctl restart network。 -
检查DNS配置 执行
ping -c 4 mirrorlist.centos.org。
若能解析并ping通:说明DNS正常,问题可能在于yum源本身,可直接跳至第4步。
若无法解析:需要配置可靠的DNS服务器,如Google的公共DNS 。 -
配置DNS服务器 编辑DNS配置文件:
sudo vi /etc/resolv.conf,确保其中有有效的DNS地址,
例如:
nameserver 8.8.8.8
nameserver 8.8.4.4
保存后,再次尝试步骤2。 配置完成后,应该可以成功解析 mirrorlist.centos.org 等域名。
如果问题依旧,则是 yum 源的问题,需要更换。
- 更换yum源(推荐方案) 这是最常见且有效的解决方法,即用国内镜像替换默认源。
以换为阿里云源为例:
a. 备份原配置文件:`
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
b. 下载新repo文件(针对CentOS 7):
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
c. 清理并重建缓存:
sudo yum clean all
sudo yum makecache 执行
yum makecache
成功后,会显示元数据缓存已建立。之后便可正常使用 yum 命令安装软件了。
- 其他备选方案 -
- 使用vault.centos.org:
如果系统版本较旧(如7.9.2009),官方镜像已迁移至vault仓库,可手动修改repo文件中的baseurl指向 http://vault.centos.org/… 。
禁用fastestmirror插件:偶尔该插件会导致问题,可编辑/etc/yum/pluginconf.d/fastestmirror.conf,将enabled=1改为enabled=0。
更多推荐

所有评论(0)