centos下安装yum

在搭建storm中需要安装python2.6.centos中默认安装的是python2.4.关于python的升级见文章:http://wind35.iteye.com/admin/categories/292186

升级后在运行yum出现问题

  
There was a problem importing one of the Python modules
   required to run yum. The error leading to this problem was:
   No module named yum
   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.6.1 (r261:67515, Aug 7 2010, 11:36:17) 
      [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)]
      If you cannot solve this problem yourself, please go to the yum faq at:
       http://wiki.linux.duke.edu/YumFaq
    提示当前版本是2.6.1可能版本不匹配。没有yum依赖的包。

头脑一热既然yum不兼容,则想着卸载yum重新安装。卸载yum是大忌在linux中。卸载后安装比较麻烦。yum完全安装需要:

yum-3.2.22-33.el5.centos.noarch.rpm

yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm

yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm

在三个包在没有yum的情况下比较难找,好在在centos的安装文件中有安装如下:

  
mkdir /test/media #创建挂在目录
    mnt /dev/dvd /test/media #挂在dvd
    cd /test/media/centos
    rpm -ivh yum-3.2.22-33.el5.centos.noarch.rpm 
             yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm 
             yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm

由于升级了python,此时运行yum还是会报错,只需要修改yum配置文件让yum用旧版本的python运行即可:

  
vi /usr/bin/yum将
   #!/usr/bin/python
   改为:
   #!/usr/bin/python2.4

使用python升级yum:

  
安装EPEL的rpm包
   rpm -ivh http://download.slogra.com/epel-release-5-4.noarch.rpm
   yum升级python
   yum -y install python26
   备份老的python版本,并使用新python版本
   mv /usr/bin/python /usr/bin/python.old
   ln -s /usr/bin/python26 /usr/bin/python
   vi /usr/bin/yum
   将第一行的python后加上2.4,即第一行改为:
   #!/usr/bin/python2.4

参考文章:

http://blog.slogra.com/post-235.html

http://blog.sina.com.cn/s/blog_62c8f3c901012s5c.html

http://blog.csdn.net/oyzl68/article/details/22932227

http://blog.chinaunix.net/uid-29020-id-3886291.html

相关推荐