yum安装及常遇问题解决

  • yum安装及常遇问题解决 
     

    Red Hat Enterprise Linux AS release 4 (Nahant Update 4)简称as4.

    Linux上常用的安装和升级工具主要有yum和apt,其中yum能更好的解决rpm的依存性问题,推荐使用yum。
     
    在标准的Redhat Enterprise Linux上,默认没有安装yum,需要单独下载并安装。
     
    以下是安装yum的步骤:
     
    1、首先安装yum和相关的rpm包。
     
    注意:本安装包只提供给as4系统之用 
     
    http://www.swsoft.com.cn/downloads/Prima/Tools/yum_forAS4.tar.gz
    http://www.haoxm.net/tools/yum_forAS4.tar.gz下载yum_forAS4.tar.gz。
     
    2、解压缩并安装。

    [root@DEV-191 aio]# tar zxvf yum_forAS4.tar.gz
    yum_forAS4/
    yum_forAS4/CentOS-Base.repo
    yum_forAS4/python-elementtree-1.2.6-7.el4.rf.i386.rpm
    yum_forAS4/python-urlgrabber-2.9.7-1.2.el4.rf.noarch.rpm
    yum_forAS4/yum-2.4.2-0.4.el4.rf.noarch.rpm
    yum_forAS4/sqlite-2.8.16-1.2.el4.rf.i386.rpm
    yum_forAS4/python-sqlite-1.0.1-1.2.el4.rf.i386.rpm

    [root@DEV-191 aio]# cd yum_forAS4

    [root@DEV-191 yum_forAS4]# rpm -ivh *.rpm
    警告:python-elementtree-1.2.6-7.el4.rf.i386.rpm: V3 DSA ?章:NOKEY, key ID 6b8d79e6
    ??中...                     ########################################### [100%]
       1:sqlite                 ########################################### [ 20%]
       2:python-sqlite          ########################################### [ 40%]
       3:python-urlgrabber      ########################################### [ 60%]
       4:python-elementtree     ########################################### [ 80%]
       5:yum                    ########################################### [100%]

    3. 将解压缩后得到的CentOS-Base.repo复制到/etc/yum.repos.d/目录里边.

    注意:本CentOS-Base.repo文件只提供给as4系统之用

    [root@DEV-191 yum_forAS4]# cp CentOS-Base.repo /etc/yum.repos.d/


    4. 执行如下命令导入GPG Key.


    [root@DEV-191 yum_forAS4]# rpm --import 
    http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4

     或

    [root@DEV-191 yum_forAS4]# rpm --import http://www.haoxm.net/tools/RPM-GPG-KEY-CentOS-4


    yum安装完毕,可以使用。yum的主要参数包括search/install/upgrade/remove

    [root@DEV-191 yum_forAS4]# yum
    You need to give some command
    usage: yum [options] < update | install | info | remove | list |
        clean | provides | search | check-update | groupinstall |
        groupupdate | grouplist | groupinfo | groupremove |
        makecache | localinstall | erase | upgrade | whatprovides |
        localupdate | resolvedep | shell | deplist >
    options:
      -h, --help            show this help message and exit
      -t, --tolerant        be tolerant of errors
      -C                    run entirely from cache, don't update cache
      -c [config file]      config file location
      -R [minutes]          maximum command wait time
      -d [debug level]      debugging output level
      -e [error level]      error output level
      -y                    answer yes for all questions
      --version             show Yum version and exit
      --installroot=[path]  set install root
      --enablerepo=[repo]   enable one or more repositories (wildcards allowed)
      --disablerepo=[repo]  disable one or more repositories (wildcards allowed)
      --exclude=[package]   exclude package(s) by name or glob
      --obsoletes           enable obsoletes processing during updates
      --noplugins           disable Yum plugins

     

    常遇到问题:

    1.

    64位linux中运行yum出现以下的错误:

    There was a problem importing one of the Python modules
    required to run yum. The error leading to this problem was:

       /usr/lib/python2.3/site-packages/cElementTree.so: cannot open shared object file: No such file or directory

    Please install a package which provides this module, or
    verify that the module is installed correctly.

    It's possible that the above module doesn't match the
    current version of Python, which is:
    2.3.4 (#1, Feb 18 2008, 17:16:53)
    [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)]

    If you cannot solve this problem yourself, please go to
    the yum faq at:
      
    http://wiki.linux.duke.edu/YumFaq

     

    原因是:python-elementtree-1.2.6-7.el4.rf.i386.rpm是针对32位系统的。

    解决方法:下载针对64位的python-elementtree-1.2.6-7.el4.rf.x86_64.rpm重新安装即可。

    64位的python-elementtree-1.2.6-7.el4.rf.x86_64.rpm下载地址:http://rpm.pbone.net/index.php3/stat/4/idpl/9514719/dir/redhat_el_4/com/python-elementtree-1.2.6-7.el4.rf.x86_64.rpm.html

     

    2. 经常遇到yum无法使用都是由于python的版本和yum不匹配导致。验证当前版本是否支持yum

    python2.5不支持yum,如下,

    [root@alu bin]# /usr/local/gemini/gtf/bin/python
    Python 2.5 Stackless 3.1b3 060516 (release25-maint, Mar  9 2008, 08:38:34)
    [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-47)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import yum
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named yum
    >>>


    默认的python2.3支持yum,如下,

    [root@sherrytest build]# /usr/bin/python
    Python 2.3.4 (#1, Feb 18 2008, 17:16:53)
    [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import yum
    >>>


    3. 修改yum中所找的python来解决,有时候你的系统中安装了多个python,我们需要让yum查找它所需要的那个python,打开/usr/bin/yum文件,默认是查找/usr/bin/python.如果我们的支持yum的python不是这个路径请修改该文件的pthon查找路径。

    [root@sherrytest build]# vi /usr/bin/yum
    #!/usr/bin/python
    import sys

     

  • 第3楼  电脑学习 发站内信息 发布日期:2011-05-06 21:35:13

    升级Python而导致的YUM服务无法使用的修复方法
    2009年2月6日 阅读评论 发表评论 由于YUM包管理是使用Python编写的,因此如果单独对Python进行升级可能会导致YUM服务无法使用。

    出现这种情况的主要原因在于新安装的Python没有YUM服务所依赖的Packages。

    可以尝试在Python中执行import yum语句,如果Python此时抛出异常则表示YUM无法正常运行。

    一般情况下出现的问题为:No module named rpm,如果这时没有rpm-python的安装包,那么就需要来重新build一个,这个package被包含在了rpm代码当中,所以先要到rpm.org网站上下载对应机器上rpm版本的源码包,然后解压,执行./configure,进入python子目录,执行make install。安装完成后,退出python子目录,执行python,再次import yum,查看是否不再出现No module named rpm,如果依然出现可以检查一下安装路径的配置。需要注意的是:1.没有必要对整个rpm进行安装,只需要对python子目录的部分进行安装;2.在执行import yum前,一定要先退出python子目录,否则python会以当前目录下的rpm目录作为rpm包的目录位置,而不会去引用site-packages目录下的rpm,会导致出现No module named _rpm异常。

    rpm下载地址http://rpm.org/wiki/Download

    除了rpm-python,其他需要的一些package:

    urlgrabber http://linux.duke.edu/projects/urlgrabber/download/
    iniparse http://code.google.com/p/iniparse/
    yum-metadata-parser http://yum.baseurl.org/download/yum-metadata-parser/

    解压后执行python setup.py install,进行安装。

    最后再次在Python执行import yum,如果不在抛出异常则表示修复成功。这时yum就可以正常使用了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值