黄大哥 發表於 2024-4-2 00:00:00

Linux中yum管理工具被误删的解决办法

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        今天在安装程序时,发现有一个插件未安装,我就随手敲了一个命令,看都没看<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode9" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        yum remove yum</div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>然后就杯具了...</span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode10" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        # yum <br>
        -bash: /usr/bin/yum: No such file or directory</div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'> </span></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        这个粗心的手误倒不至于让整个系统瘫痪,yum 却无法使用了。于是,我试着折腾了一番<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode11" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        rpm -ivh --nodeps &lt;a href="http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm"&gt;http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm&lt;/a&gt; <br>
        rpm -ivh --nodeps &lt;a href="http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm"&gt;http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm&lt;/a&gt; <br>
        rpm -ivh --nodeps &lt;a href="http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm<br>
        关于rpm --nodeps的解释<br>
        <br>
        --nodeps don't verify package dependencies</div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>接下来,再次尝试输入yum,结果再次出现莫名错误</span></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode12" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        # yum <br>
        There was a problem importing one of the Python modules <br>
        required to run yum. The error leading to this problem was: <br><br>
        libxml2.so.2: cannot open shared object file: No such file or directory <br><br>
        Please install a package which provides this module, or <br>
        verify that the module is installed correctly. <br><br>
        It's possible that the above module doesn't match the <br>
        current version of Python, which is: <br>
        2.4.3 (#1, Nov 11 2010, 13:30:19) <br>
         <br><br>
        If you cannot solve this problem yourself, please go to <br>
        the yum faq at: <br>
        &lt;a href="http://wiki.linux.duke.edu/YumFaq"&gt;http://wiki.linux.duke.edu/YumFaq&lt;/a&gt; </div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        因为yum调用的是python,运行 Python,试下是否可行<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode13" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        # python <br>
        Python 2.4.3 (#1, Nov 11 2010, 13:30:19) <br>
        on linux2 <br>
        Type "help", "copyright", "credits" or "license" for more information. <br>
        &gt;&gt;&gt; import yum <br>
        Traceback (most recent call last): <br>
        File "&lt;stdin&gt;", line 1, in ? <br>
        File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 54, in ? <br>
        import transactioninfo <br>
        File "/usr/lib/python2.4/site-packages/yum/transactioninfo.py", line 31, in ? <br>
        from sqlitesack import YumAvailablePackageSqlite <br>
        File "/usr/lib/python2.4/site-packages/yum/sqlitesack.py", line 26, in ? <br>
        import yumRepo <br>
        File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 32, in ? <br>
        import sqlitecachec <br>
        File "/usr/lib64/python2.4/site-packages/sqlitecachec.py", line 19, in ? <br>
        import _sqlitecache <br>
        ImportError: libxml2.so.2: cannot open shared object file: No such file or directory <br>
        &gt;&gt;&gt; </div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>提示缺少libxml2.so.2,安装一下试试</span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode14" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        rpm -ivh &lt;a href="http://mirrors.163.com/centos/5/os/x86_64/CentOS/libxml2-2.6.26-2.1.2.8.x86_64.rpm<br>
        再次测试运行下yum命令,结果正常了,大喜<br>
        <br>
        # yum <br>
        Loaded plugins: fastestmirror <br>
        You need to give some command <br>
        usage: yum COMMAND <br><br>
        List of Commands: <br><br>
        check-update Check for available package updates <br>
        clean Remove cached data <br>
        deplist List a package's dependencies <br>
        downgrade downgrade a package <br>
        erase Remove a package or packages from your system <br>
        groupinfo Display details about a package group <br>
        groupinstall Install the packages in a group on your system <br>
        grouplist List available package groups <br>
        groupremove Remove the packages in a group from your system <br>
        help Display a helpful usage message <br>
        info Display details about a package or group of packages <br>
        install Install a package or packages on your system <br>
        list List a package or groups of packages <br>
        localinstall Install a local RPM <br>
        makecache Generate the metadata cache <br>
        provides Find what package provides the given value <br>
        reinstall reinstall a package <br>
        repolist Display the configured software repositories <br>
        resolvedep Determine which package provides the given dependency <br>
        search Search package details for the given string <br>
        shell Run an interactive yum shell <br>
        update Update a package or packages on your system <br>
        upgrade Update packages taking obsoletes into account <br><br><br>
        options: <br>
        -h, --help show this help message and exit <br>
        -t, --tolerant be tolerant of errors <br>
        -C run entirely from cache, don't update cache <br>
        -c config file location <br>
        -R maximum command wait time <br>
        -d debugging output level <br>
        --showduplicates show duplicates, in repos, in list/search commands <br>
        -e error output level <br>
        -q, --quiet quiet operation <br>
        -v, --verbose verbose operation <br>
        -y answer yes for all questions <br>
        --version show Yum version and exit <br>
        --installroot= set install root <br>
        --enablerepo= enable one or more repositories (wildcards allowed) <br>
        --disablerepo= disable one or more repositories (wildcards allowed) <br>
        -x , --exclude= <br>
        exclude package(s) by name or glob <br>
        --disableexcludes= <br>
        disable exclude from main, for a repo or for <br>
        everything <br>
        --obsoletes enable obsoletes processing during updates <br>
        --noplugins disable Yum plugins <br>
        --nogpgcheck disable gpg signature checking <br>
        --disableplugin= <br>
        disable plugins by name <br>
        --enableplugin= <br>
        enable plugins by name <br>
        --skip-broken skip packages with depsolving problems <br>
        --color=COLOR control whether color is used <br><br>
        Plugin Options: </div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        最后,赶紧更新一下系统吧<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode15" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        yum update</div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>好了 这样yum问题就完全解决了!</span></p>
頁: [1]
查看完整版本: Linux中yum管理工具被误删的解决办法