步骤
1、先卸载原有的yum
[root@creep ~]#rpm -e `rpm -qa | grep yum` --nodeps
2、查看yum的情况
[root@creep ~]# rpm -qi yum
package yum is not installed
3、先到http://mirrors.163.com/centos/6/os/x86_64/Packages/目录下下载yum-3.2.29-73.el6.centos.noarch.rpm
[root@creep ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-73.el6.centos.noarch.rpm
4、尝试安装yum
[root@creep ~]# rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm
warning: yum-3.2.29-73.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
python-iniparse is needed by yum-3.2.29-73.el6.centos.noarch
python-urlgrabber >= 3.9.1-10 is needed by yum-3.2.29-73.el6.centos.noarch
yum-metadata-parser >= 1.1.0 is needed by yum-3.2.29-73.el6.centos.noarch
yum-plugin-fastestmirror is needed by yum-3.2.29-73.el6.centos.noarch
5、根据上面出现的结果,还需要下载python-iniparse、python-urlgrabber、yum-metadata-parser与yum-plugin-fastestmirror
[root@creep ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
[root@creep ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm
[root@creep ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
[root@creep ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
5、安装python-iniparse、python-urlgrabber与yum-metadata-parser
[root@creep ~]# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
[root@creep ~]# rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm
[root@creep ~]#rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
6、在安装yum-plugin-fastestmirror与yum出现以下情况
[root@creep ~]# rpm -ivh yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm
warning: yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
yum >= 3.0 is needed by yum-plugin-fastestmirror-1.1.30-37.el6.noarch
[root@creep ~]# rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm
warning: yum-3.2.29-73.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
yum-plugin-fastestmirror is needed by yum-3.2.29-73.el6.centos.noarch
说明他们相互依赖,应该下达这样的命令
[root@creep ~]# rpm -ivh yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm yum-3.2.29-73.el6.centos.noarch.rpm
7、前往http://mirrors.163.com/.help/下载CentOS6-Base-163.repo文件
[root@creep ~]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
[root@creep ~]# vim CentOS6-Base-163.repo //将修改文件里的$releasever改为6
[root@creep ~]# mv CentOS6-Base-163.repo /etc/yum.repos.d/CentOS6-Base-163.repo
8、清空缓存与重新建立缓存
[root@creep ~]# yum clean all
[root@creep ~]# yum makecache