• yum clean all 后导致yum报错排查解决方案



    1、yum clean all 后导致yum报错

    一开始因为yum找不到包,所以打算更新一下yum仓库,结果遇到坑的博客直接yum不能使用了
    使用yum update报错

    [root@iZbp17aznee2whyk4k44vjZ ~]# yum update httpd
    base                                                                                                                                                                                                                        | 3.6 kB  00:00:00     
    extras                                                                                                                                                                                                                      | 2.9 kB  00:00:00     
    updates                                                                                                                                                                                                                     | 2.9 kB  00:00:00     
    No packages marked for update
    
    • 1
    • 2
    • 3
    • 4
    • 5

    感觉是yum的仓库给清理里没有包了

    [root@iZbp17aznee2whyk4k44vjZ ~]# yum update httpd-tools
    Resolving Dependencies
    --> Running transaction check
    ---> Package httpd-tools.x86_64 0:2.4.6-90.el7.centos will be updated
    --> Processing Dependency: httpd-tools = 2.4.6-90.el7.centos for package: httpd-2.4.6-90.el7.centos.x86_64
    ---> Package httpd-tools.x86_64 0:2.4.6-97.el7.centos.5 will be an update
    --> Finished Dependency Resolution
    Error: Package: httpd-2.4.6-90.el7.centos.x86_64 (@base)
               Requires: httpd-tools = 2.4.6-90.el7.centos
               Removing: httpd-tools-2.4.6-90.el7.centos.x86_64 (@base)
                   httpd-tools = 2.4.6-90.el7.centos
               Updated By: httpd-tools-2.4.6-97.el7.centos.5.x86_64 (updates)
                   httpd-tools = 2.4.6-97.el7.centos.5
               Available: httpd-tools-2.4.6-95.el7.centos.x86_64 (base)
                   httpd-tools = 2.4.6-95.el7.centos
               Available: httpd-tools-2.4.6-97.el7.centos.x86_64 (updates)
                   httpd-tools = 2.4.6-97.el7.centos
               Available: httpd-tools-2.4.6-97.el7.centos.1.x86_64 (updates)
                   httpd-tools = 2.4.6-97.el7.centos.1
               Available: httpd-tools-2.4.6-97.el7.centos.2.x86_64 (updates)
                   httpd-tools = 2.4.6-97.el7.centos.2
               Available: httpd-tools-2.4.6-97.el7.centos.4.x86_64 (updates)
                   httpd-tools = 2.4.6-97.el7.centos.4
     You could try using --skip-broken to work around the problem
     You could try running: rpm -Va --nofiles --nodigest
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25

    看到上面最后一句报错让我尝试rpm-Va --nofiles --nodigest

    [root@iZbp17aznee2whyk4k44vjZ ~]#rpm -qa|grep yum|xargs rpm -e --nodeps 
    warning: /etc/yum/pluginconf.d/fastestmirror.conf saved as /etc/yum/pluginconf.d/fastestmirror.conf.rpmsave
    warning: /etc/yum.conf saved as /etc/yum.conf.rpmsave
    [root@iZbp17aznee2whyk4k44vjZ ~]# rpm -qa |grep yum
    
    • 1
    • 2
    • 3
    • 4

    结果返回为空,我的yum依赖都没了
    在这里插入图片描述
    后来到网站上找了几个下载依赖的地址都下载报错
    在这里插入图片描述

    Connecting to centos.ustc.edu.cn (centos.ustc.edu.cn)|202.141.160.110|:80... connected.
    HTTP request sent, awaiting response... 404 Not Found
    2022-10-19 10:13:06 ERROR 404: Not Found.
    
    • 1
    • 2
    • 3

    后来我直接访问这个地址直接是404
    其实直接到官网下载就可以了
    这时候你yum makecache肯定是-bash: /usr/bin/yum: No such file or directory
    因为你这时候yum依赖
    依旧还是没下载下来在这里插入图片描述

    2、最终解决方案

    到官网下载对应依赖
    在这里插入图片描述
    你也可以直接

    [root@iZbp17aznee2whyk4k44vjZ ~]#wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
    [root@iZbp17aznee2whyk4k44vjZ ~]#wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
    [root@iZbp17aznee2whyk4k44vjZ ~]#wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
    
    • 1
    • 2
    • 3

    在这里插入图片描述

    然后你在安装一下

    rpm -ivh yum-*
    
    • 1

    在这里插入图片描述
    然后看安装结果
    在这里插入图片描述
    成功
    yum一下看工具都回来了
    在这里插入图片描述
    如果你的yum源还是有问题建议你还是更新一下

    3、更新yum源

    切换到yum文件夹

    cd /etc/yum.repos.d
    
    • 1

    将原来的yum源给备份

    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    
    • 1

    指定路径下载

    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    
    • 1

    清除缓存

    yum clean all
    
    • 1

    生成缓存

    yum makecache
    
    • 1

    实际测试,可以用了
    在这里插入图片描述

    总结

    yum工具没了重新安装yum
    对应的三个工具
    yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
    yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
    yum-3.4.3-168.el7.centos.noarch.rpm

  • 相关阅读:
    Mybatis——一对多关联映射
    Java读源码之Netty深入剖析
    Linux 7:mybash的实现和进程间通信
    UE4(unreal engine)虚幻引擎中安装light explorer灯光管理器插件
    PhaGCN2:病毒聚类
    QT之QChart的简介
    【SpringBoot】薛定谔的yaml
    PHP常用的数组函数
    EVE-NG桥接虚拟网卡实现与虚拟机通讯
    js promise.all
  • 原文地址:https://blog.csdn.net/qq_45547688/article/details/127404238