配置阿里云yum镜像源报错: One of the configured repositories failed (CentOS-$releasever - Base - mirrors.aliyun

1、配置阿里云yum镜像源报错

原因是$releasever找不到相关的变量值,需要改一下配置文件,手动指定一下相关的发行版本,报错如下:

 One of the configured repositories failed (CentOS-$releasever - Base - mirrors.aliyun.com),
 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=base ...

     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 base
        or
            subscription-manager repos --disable=base

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

failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try.
2、解决方法:


直接编辑 /etc/yum.repos.d/CentOS-Base.repo文件,将所有 $releasever替换为具体的版本号(例如 7

cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
3. 验证修复结果

完成修复后,执行以下命令测试:

# 清理旧缓存
yum clean all

# 重新建立元数据缓存
yum makecache

# 测试列出可用更新
yum list available

需要用yum下载docker,但yum源加了docker社区版后,发现,还是有报错,执行逻辑:
 

4、​​安装 yum-utils包(它提供了 yum-config-manager工具)​
yum install -y yum-utils

5、执行命令加载docker yum 源,添加阿里云 Docker CE 镜像仓库​
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
6、​​更新 Yum 缓存​
yum makecache

然后发现报错:

https://mirrors.aliyun.com/docker-ce/linux/centos/%24releasever/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
正在尝试其它镜像。
To address this issue please refer to the below wiki article 

https://wiki.centos.org/yum-errors

If above article doesn't help to resolve this issue please use https://bugs.centos.org/.



 One of the configured repositories failed (Docker CE Stable - x86_64),
 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=docker-ce-stable ...

     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 docker-ce-stable
        or
            subscription-manager repos --disable=docker-ce-stable

     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=docker-ce-stable.skip_if_unavailable=true

failure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try.
https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

原因:

错误的核心是Docker CE 的 repo 文件配置中的 %24releasever 找不到导致,导致 URL 拼写错误。

  • 错误信息显示:链接1%24releasever/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

  • %24是 $的 URL 编码,说明 $releasever没有被替换成实际的版本号

  • 直接访问了不存在的 URL:https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/x86_64/stable/

解决方法:

批量修改 $releasever为实际版本号命令,如7

sed -i 's/\$releasever/7/g' /etc/yum.repos.d/docker-ce.repo

重建缓存

yum makecache

重新安装 Docker

yum install -y docker-ce

结果遇到如下错误,这是阿里云镜像的docker-compose-plugin包的问题,换成其他镜像如清华镜像源即可

安装  5 软件包 (+5 依赖软件包)

总下载量:114 M
安装大小:401 M
Downloading packages:
(1/10): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                                                                                                                                            |  40 kB  00:00:00     
warning: /var/cache/yum/x86_64/$releasever/docker-ce-stable/packages/containerd.io-1.6.33-3.1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY                                         ] 4.2 MB/s |  45 MB  00:00:16 ETA 
containerd.io-1.6.33-3.1.el7.x86_64.rpm 的公钥尚未安装
(2/10): containerd.io-1.6.33-3.1.el7.x86_64.rpm                                                                                                                                                                         |  35 MB  00:00:10     
(3/10): docker-buildx-plugin-0.14.1-1.el7.x86_64.rpm                                                                                                                                                                    |  14 MB  00:00:11     
(4/10): docker-ce-26.1.4-1.el7.x86_64.rpm                                                                                                                                                                               |  27 MB  00:00:07     
(5/10): docker-ce-rootless-extras-26.1.4-1.el7.x86_64.rpm                                                                                                                                                               | 9.4 MB  00:00:02     
docker-compose-plugin-2.27.1-1 FAILED                                          
https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-compose-plugin-2.27.1-1.el7.x86_64.rpm: [Errno -1] 软件包与预期下载的不符。建议:运行 yum --enablerepo=docker-ce-stable clean metadata|  97 MB  00:00:03 ETA 
正在尝试其它镜像。
(6/10): fuse3-libs-3.6.1-4.el7.x86_64.rpm                                                                                                                                                                               |  82 kB  00:00:00     
(7/10): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm                                                                                                                                                                         |  54 kB  00:00:00     
(8/10): slirp4netns-0.4.3-4.el7_8.x86_64.rpm                                                                                                                                                                            |  81 kB  00:00:00     
(9/10): docker-ce-cli-26.1.4-1.el7.x86_64.rpm                                                                                                                                                                           |  15 MB  00:00:11     


Error downloading packages:
  docker-compose-plugin-2.27.1-1.el7.x86_64: [Errno 256] No more mirrors to try.

如何换清华镜像源:

rm -f /etc/yum.repos.d/docker-ce.repo
yum --enablerepo=docker-ce-stable clean metadata
yum clean all

sed -i 's|https://download.docker.com|https://mirrors.tuna.tsinghua.edu.cn/docker-ce|g' /etc/yum.repos.d/docker-ce.repo

yum-config-manager \
        --add-repo \
        https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo

参考文章:

Error downloading packages: docker-compose-plugin-2.27.1-1.el7.x86_64: [Errno 256] No more mirrors_docker-compose-plugin-2.27.1-1 failed-优快云博客

配置 Docker 镜像源,添加清华镜像源的 repo 配置文件后记得重新执行:
 

sed -i 's/\$releasever/7/g' /etc/yum.repos.d/docker-ce.repo

然后重新执行:
 

yum install -y docker-ce 

发现安装成功,问题解决!

[root@server-0001 yum.repos.d]# cat /etc/yum.repos.d/CentOS-Base.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos-vault/7.9.2009/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 [root@server-0001 yum.repos.d]#[root@server-0001 yum.repos.d]# yum makecache fast Loaded plugins: fastestmirror Determining fastest mirrors * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com http://mirrors.aliyun.com/centos-vault/7.9.2009/os/aarch64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errors If above article doesn't help to resolve this issue please use https://bugs.centos.org/. One of the configured repositories failed (CentOS-7 - Base - mirrors.aliyun.com), 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=base ... 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 base or subscription-manager repos --disable=base 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=base.skip_if_unavailable=true failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try. http://mirrors.aliyun.com/centos-vault/7.9.2009/os/aarch64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found [root@server-0001 yum.repos.d]#
09-27
我在更新缓存yum仓库中遇到如下问题:[root@centos ~]# yum makecache Loaded plugins: fastestmirror, langpacks Bad id for repo: elasticsearch-7.×, byte = � 16 Loading mirror speeds from cached hostfile epel/x86_64/metalink | 4.8 kB 00:00:00 * base: mirrors.aliyun.com * centosplus: mirrors.aliyun.com * contrib: mirrors.aliyun.com * epel: repo.jing.rocks * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com base | 3.6 kB 00:00:00 base-archive | 3.6 kB 00:00:00 centosplus | 2.9 kB 00:00:00 http://mirrors.aliyun.com/centos/7/contrib/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errors If above article doesn't help to resolve this issue please use https://bugs.centos.org/. ^Chttp://mirrors.cloud.aliyuncs.com/centos/7/contrib/x86_64/repodata/repomd.xml: [Errno 14] curl#56 - "Callback aborted" Trying other mirror. ^Chttp://mirrors.aliyuncs.com/centos/7/contrib/x86_64/repodata/repomd.xml: [Errno 14] curl#56 - "Callback aborted" Trying other mirror. One of the configured repositories failed (CentOS-7 - Contrib - mirrors.aliyun.com), 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=contrib ... 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 contrib or subscription-manager repos --disable=contrib 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=contrib.skip_if_unavailable=true failure: repodata/repomd.xml from contrib: [Errno 256] No more mirrors to try. http://mirrors.aliyun.com/centos/7/contrib/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found http://mirrors.cloud.aliyuncs.com/centos/7/contrib/x86_64/repodata/repomd.xml: [Errno 14] curl#56 - "Callback aborted" http://mirrors.aliyuncs.com/centos/7/contrib/x86_64/repodata/repomd.xml: [Errno 14] curl#56 - "Callback aborted" 我的/etc/yum.repos.d/CentOS-Base.repo文件中的内容如下:[base] name=CentOS-$releasever - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 我要如何修改我的错误
08-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值