yum 安装 epel-release 后出现yum doesn’t have enough cached data to continue错误的解决方案

工作中需要部署docker,由于是内网环境,无法直接访问外网,于是考虑在内网搭建yum私有源进行安装,内网服务器操作系统为centos 7.4。根据docker的官方安装方式进行安装时,要求安装 epel-release 以及 container-selinux。
于是进行同步base以及epel源,reposync base && reposync epel

到内网环境中,通过 createrepo ./的方式创建私有源,并在另一台服务器上逐步安装,当安装完毕epel-release后,再进行安装container-selinux时,出现错误。

已加载插件:fastestmirror
base                                                                                                                                                      | 3.6 kB  00:00:00


 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. 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 <repoid>

     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=<repoid>.skip_if_unavailable=true

Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again

原因是安装完毕 epel-release 后, 会在 /etc/yum.repo.d/目录中添加 epel.repo 以及 epel-testing.repo 两个配置文件,配置文件中包含 container-selinux 的yum源。

解决方法:

  1. 继续同步epel.repo中指定的yum源,并修改本地/etc/yum.repo.d/epel.repo对应的yum源路径。
  2. 找一台可下载container-selinux相关rpm包的服务器下载关联安装包进行安装。

我目前是使用的第二种解决方案,在一台能上外网的机器中执行如下命令:

# 挂载位置轻喷 嘻嘻
sudo docker rum --rm -v /container-selinux:/data -it centos:latest /bin/bash -c "yum install -y epel-release && yum install container-selinux --downloadonly --downloaddir=/data"

然后将/container-selinux/ 中container-selinux*.rpm 拷贝到目标服务器中,执行rpm安装命令即可

sudo rpm -ivh container-selinux*.rpm

由于人也比较懒,所以安装docker-ce相关的内容时也不会去配置GPG公钥,安装的时候跳过即可

sudo yum install -y docker-ce docker-ce-cli containerd.io --nogpgcheck
posted @ 2019-07-11 11:09  Ant°  阅读(3820)  评论(0编辑  收藏  举报