解决yum makecache报错

新装一台centos7.9,更换yum源后就是一套yum clean all + yum makecache,啪!很快啊!然后就报错了…
接着尝试换其他yum源,仍然是这个报错(挠头)
再重新装一遍系统,还是这个报错(疯狂挠头)

在这里插入图片描述

仔细看了看阿里163清华的repo文件,发现都用的$releasever来引用变量,但是似乎没生效呀,干脆替换成绝对路径算了

在这里插入图片描述

芜湖!成功了

在这里插入图片描述


以下是详细步骤

报错信息

[root@7 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirrors.cloud.aliyuncs.com
 * extras: mirrors.cloud.aliyuncs.com
 * updates: mirrors.cloud.aliyuncs.com
base                                                                          | 1.6 kB  00:00:00
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno -1] Error importing                                                           repomd.xml for base: Damaged repomd.xml file
Trying other mirror.
base                                                                          | 1.6 kB  00:00:00
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno -1] Error importing repomd                                                          .xml for base: Damaged repomd.xml file
Trying other mirror.
base                                                                          | 1.6 kB  00:00:00
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno -1] Error importing repomd.x                                                          ml for base: Damaged repomd.xml file
Trying other mirror.


 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.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno -1] Error importing                                                           repomd.xml for base: Damaged repomd.xml file
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno -1] Error importing repomd                                                          .xml for base: Damaged repomd.xml file
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno -1] Error importing repomd.x                                                          ml for base: Damaged repomd.xml file

开始替换

vi /etc/yum.repos.d/CentOS-Base.repo
:%s/$releasever/7.9.2009/g					 //将所有$releasever替换成7.9.2009
:%s/CentOS-7.9.2009/CentOS-Base/g			 //将CentOS-7.9.2009替换成文件名CentOS-Base
:wq!

注意事项
$releasever应替换成相对应的系统版本,别盲目替换成我的7.9.2009
name=CentOS-Base这里也要改成你自己的文件名,比如阿里云的文件名是Centos-7.repo,那就改成name=CentOS-7


以下是我已经改好在用的清华yum源,centos7.9直接复制可用

# 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-Base - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.9.2009&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-Base - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.9.2009&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-Base - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.9.2009&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-Base - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.9.2009&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐