侧边栏壁纸
博主头像
YOUZI

我依旧在追寻自由的路上

  • 累计撰写 85 篇文章
  • 累计创建 10 个分类
  • 累计创建 27 个标签

目 录CONTENT

文章目录

Centos7.6Yum失败

柚子
原创 / 2024-07-19 / 0 评论 / 0 点赞 / 75 阅读 / 0 字
温馨提示:
本文最后更新于62天前,若内容或图片失效,请留言反馈。 部分素材来自网络,若不小心影响您的利益,请联系 站长 删除。

背景

本地虚拟机安装docker失败,不,应该说是yum安装软件都失败,前几次安装也失败,没记录,时间长了就忘了咋解决的,这次就记录一下。

[root@blog ~]# yum  install -y vim
已加载插件: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

解决

更换yum源

备份

sudo cp -r /etc/yum.repos.d /etc/yum.repos.d.bak

删除

sudo rm -f /etc/yum.repos.d/*.repo

添加

sudo vi /etc/yum.repos.d/CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY.cnpmjs.org
enabled=1

[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY.cnpmjs.org
enabled=1

[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY.cnpmjs.org
enabled=1

清理

sudo yum clean all

更新

sudo yum makecache

附录

如果遇到下面情况

从 http://mirrors.aliyun.com/centos/RPM-GPG-KEY.cnpmjs.org 检索密钥


获取 GPG 密钥失败:[Errno 14] HTTP Error 404 - Not Found

输入下面

rpm --import https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

结果

[root@blog ~]# yum -y install docker-ce
已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.3.26.1.4-1.el7 将被 安装
--> 正在处理依赖关系 container-selinux >= 2:2.74,它被软件包 3:docker-ce-26.1.4-1.el7.x86_64 需要
--> 正在处理依赖关系 containerd.io >= 1.6.24,它被软件包 3:docker-ce-26.1.4-1.el7.x86_64 需要
--> 正在处理依赖关系 docker-ce-cli,它被软件包 3:docker-ce-26.1.4-1.el7.x86_64 需要
--> 正在处理依赖关系 docker-ce-rootless-extras,它被软件包 3:docker-ce-26.1.4-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.119.2-1.911c772.el7_8 将被 安装
---> 软件包 containerd.io.x86_64.0.1.6.33-3.1.el7 将被 安装
---> 软件包 docker-ce-cli.x86_64.1.26.1.4-1.el7 将被 安装
--> 正在处理依赖关系 docker-buildx-plugin,它被软件包 1:docker-ce-cli-26.1.4-1.el7.x86_64 需要
--> 正在处理依赖关系 docker-compose-plugin,它被软件包 1:docker-ce-cli-26.1.4-1.el7.x86_64 需要
---> 软件包 docker-ce-rootless-extras.x86_64.0.26.1.4-1.el7 将被 安装
--> 正在检查事务
---> 软件包 docker-buildx-plugin.x86_64.0.0.14.1-1.el7 将被 安装
---> 软件包 docker-compose-plugin.x86_64.0.2.27.1-1.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

======================================================================================================================================================================================================================================================================================
 Package                                                                   架构                                                   版本                                                                         源                                                                大小
======================================================================================================================================================================================================================================================================================
正在安装:
 docker-ce                                                                 x86_64                                                 3:26.1.4-1.el7                                                               docker-ce-stable                                                  27 M
为依赖而安装:
 container-selinux                                                         noarch                                                 2:2.119.2-1.911c772.el7_8                                                    extras                                                            40 k
 containerd.io                                                             x86_64                                                 1.6.33-3.1.el7                                                               docker-ce-stable                                                  35 M
 docker-buildx-plugin                                                      x86_64                                                 0.14.1-1.el7                                                                 docker-ce-stable                                                  14 M
 docker-ce-cli                                                             x86_64                                                 1:26.1.4-1.el7                                                               docker-ce-stable                                                  15 M
 docker-ce-rootless-extras                                                 x86_64                                                 26.1.4-1.el7                                                                 docker-ce-stable                                                 9.4 M
 docker-compose-plugin                                                     x86_64                                                 2.27.1-1.el7                                                                 docker-ce-stable                                                  13 M

事务概要
======================================================================================================================================================================================================================================================================================
安装  1 软件包 (+6 依赖软件包)

总下载量:114 M
安装大小:401 M
Downloading packages:
(1/7): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                                                                                                                                                                                    |  40 kB  00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-buildx-plugin-0.14.1-1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY                                                                                     ] 2.5 MB/s |  27 MB  00:00:33 ETA
docker-buildx-plugin-0.14.1-1.el7.x86_64.rpm 的公钥尚未安装
(2/7): docker-buildx-plugin-0.14.1-1.el7.x86_64.rpm                                                                                                                                                                                                            |  14 MB  00:00:12
(3/7): containerd.io-1.6.33-3.1.el7.x86_64.rpm                                                                                                                                                                                                                 |  35 MB  00:00:34
(4/7): docker-ce-26.1.4-1.el7.x86_64.rpm                                                                                                                                                                                                                       |  27 MB  00:00:25
(5/7): docker-ce-rootless-extras-26.1.4-1.el7.x86_64.rpm                                                                                                                                                                                                       | 9.4 MB  00:00:05
(6/7): docker-ce-cli-26.1.4-1.el7.x86_64.rpm                                                                                                                                                                                                                   |  15 MB  00:00:14
(7/7): docker-compose-plugin-2.27.1-1.el7.x86_64.rpm                                                                                                                                                                                                           |  13 MB  00:00:08
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                                                                                                                  2.2 MB/s | 114 MB  00:00:51
从 https://mirrors.aliyun.com/docker-ce/linux/centos/gpg 检索密钥
导入 GPG key 0x621E9F35:
 用户ID     : "Docker Release (CE rpm) <docker@docker.com>"
 指纹       : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 来自       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                                                                                                                                1/7
  正在安装    : containerd.io-1.6.33-3.1.el7.x86_64                                                                                                                                                                                                                               2/7
  正在安装    : docker-buildx-plugin-0.14.1-1.el7.x86_64                                                                                                                                                                                                                          3/7
  正在安装    : docker-compose-plugin-2.27.1-1.el7.x86_64                                                                                                                                                                                                                         4/7
  正在安装    : 1:docker-ce-cli-26.1.4-1.el7.x86_64                                                                                                                                                                                                                               5/7
  正在安装    : docker-ce-rootless-extras-26.1.4-1.el7.x86_64                                                                                                                                                                                                                     6/7
  正在安装    : 3:docker-ce-26.1.4-1.el7.x86_64                                                                                                                                                                                                                                   7/7
  验证中      : docker-compose-plugin-2.27.1-1.el7.x86_64                                                                                                                                                                                                                         1/7
  验证中      : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                                                                                                                                2/7
  验证中      : containerd.io-1.6.33-3.1.el7.x86_64                                                                                                                                                                                                                               3/7
  验证中      : 3:docker-ce-26.1.4-1.el7.x86_64                                                                                                                                                                                                                                   4/7
  验证中      : 1:docker-ce-cli-26.1.4-1.el7.x86_64                                                                                                                                                                                                                               5/7
  验证中      : docker-ce-rootless-extras-26.1.4-1.el7.x86_64                                                                                                                                                                                                                     6/7
  验证中      : docker-buildx-plugin-0.14.1-1.el7.x86_64                                                                                                                                                                                                                          7/7

已安装:
  docker-ce.x86_64 3:26.1.4-1.el7

作为依赖被安装:
  container-selinux.noarch 2:2.119.2-1.911c772.el7_8   containerd.io.x86_64 0:1.6.33-3.1.el7   docker-buildx-plugin.x86_64 0:0.14.1-1.el7   docker-ce-cli.x86_64 1:26.1.4-1.el7   docker-ce-rootless-extras.x86_64 0:26.1.4-1.el7   docker-compose-plugin.x86_64 0:2.27.1-1.el7

完毕!

0

评论区