因为之前在使用的RedHat el5上自己对yum进行了很多改动,换成centos的源有更新python版本,造成今天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.4/site-packages/_sqlitecache.so: wrong ELF class: ELFCLASS32
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.4.3 (#1, Dec 10 2010, 17:24:35)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://wiki.linux.duke.edu/YumFaq
辗转各处查询说就是因为Centos和python的版本不匹配,在试过各种解决办法都行不通之后决定现在所有的yum包,然后再重新装一个Centos的yum源。
首先要彻底删除RHEL上的yum:rpm -aq|grep yum|xargs rpm -e --nodeps
下载新的Centos5的yum源码包:
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
安装所下载的yum包:
rpm -ivh --nodeps \python-iniparse-0.2.3-4.el5.noarch.rpm \yum-3.2.22-39.el5.centos.noarch.rpm \yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm \yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
然后给Centos的yum编辑匹配的配置文件,保存到到/etc/yum.repo.d下,内容如下:
[base]
name=CentOS-5 - Base
repo=os
baseurl=http://mirrors.163.com/centos/5/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
#released updates
[update]
name=CentOS-5 - Updates
baseurl=http://mirrors.163.com/centos/5/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-5 - Addons
baseurl=http://mirrors.163.com/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-5 - Extras
baseurl=http://mirrors.163.com/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5 - Plus
baseurl=http://mirrors.163.com/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-5 - Contrib
baseurl=http://mirrors.163.com/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
配置文件写好保存之后,就算是安装完毕了。这时再执行yum就不会报错了,然后yum -y update将必要的yum组件更新一下就好了。