一.先卸载RedHat上的yum环境
命令如下: rpm -qa|grep yum|xargs rpm -e --nodeps
二.下载CentOS yum安装包
http://vault.centos.org/5.4/os/i386/CentOS/yum-3.2.22-20.el5.centos.noarch.rpm
http://vault.centos.org/5.4/os/i386/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
http://vault.centos.org/5.4/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
http://vault.centos.org/5.4/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
三.安装上面下载的rpm安装包
命令如下:
1.rpm -ivh yum-3.2.22-20.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
2.rpm -ivh python-iniparse-0.2.3-4.el5.noarch.rpm
四.生成yum仓库文件CentOS-Base.repo,放在/etc/yum.repos.d/目录下,我用的5.4的版本,直接贴出来,文件内容如下:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-5.4 - Base - org
baseurl=http://vault.centos.org/5.4/os/i386/
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=i386&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-5.4 - Updates - org
baseurl=http://vault.centos.org/5.4/updates/i386/
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=i386&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-5.4 - Addons - org
baseurl=http://vault.centos.org/5.4/addons/i386/
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=i386&repo=addons
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-5.4 - Extras - org
baseurl=http://vault.centos.org/5.4/extras/i386/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5.4 - Plus - org
baseurl=http://vault.centos.org/5.4/centosplus/i386/
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=i386&repo=centosplus
gpgcheck=1
enabled=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-5.4 - Contrib - org
baseurl=http://vault.centos.org/5.4/contrib/i386/
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=i386&repo=contrib
gpgcheck=1
enabled=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
因为我的red-hat是 32位 Server5 的缘故,我直接将$releasever更换成了5.4,将$basesearch更换成了i386,如果你的系统是64
位的,此处需要按照你的系统具体修改.
五.清除RedHat-yum默认残留
1.yum clean metadata
2.yum clean dbcache
3.yum makecache
六.命令验证
yum update
此处建议输入n ^=^