以前工作中一直使用centos系统,突然今天新装了RedHat 5.4系统,想用VIM工具可是新装系统大家都知道没有安装此工具,大家这时肯定都会想到使用YUM安装下就可以了,可是RedHat自带的YUM源,是在收费的情况下才能使用的。于是由于咱是小农阶级没办法GOOGLE下,原来这样的情况不是我一个遇到看来已经有很多的前辈了,于是我随便点开了几个链接。查看别人的劳动成果,看完后让我有点晕。方法太多试了好多最后终于搞定,也不容易呀。      由于RedHat是自带的yum源是收费的,所以我们自然而然就想到了用他的社区版Centos的yum源。所以首先我们要卸载RedHat自带的yum的RPM包。第一 步:查看系统上安装的yum包rpm -qa | grep yum卸载安装的yum包rpm -e –nodeps  xxxxxx.rpm 第二步:首先确定系统架构。如果是i386的话则需要到http://mirrors.163.com/centos/5/os/i386/CentOS/ 找到对应的软件包如果是x86_64的话则需要到http://mirrors.163.com/centos/5/os/x86_64/CentOS/找到对应的软件包需要如下包:m2crypto-0.16-8.el5.i386.rpmpython-elementtree-1.2.6-5.i386.rpmpython-iniparse-0.2.3-4.el5.noarch.rpmpython-sqlite-1.1.7-1.2.1.i386.rpmpython-urlgrabber-3.1.0-6.el5.noarch.rpmyum-3.2.22-39.el5.centos.noarch.rpmyum-fastestmirror-1.1.16-21.el5.centos.noarch.rpmyum-metadata-parser-1.1.2-3.el5.centos.i386.rpm安装(升级)软件包在软件包的存放目录里rpm -ivh m2crypto-0.16-8.el5.i386.rpm python-elementtree-1.2.6-5.i386.rpm python-iniparse-0.2.3-4.el5.noarch.rpm python-sqlite-1.1.7-1.2.1.i386.rpm python-urlgrabber-3.1.0-6.el5.noarch.rpm yum-3.2.22-39.el5.centos.noarch.rpm yum-fastestmirror-1.1.16 21.el5.centos.noarch.rpm yum-metadata-parser-1.1.2 3.el5.centos.i386.rpm
rpm -import http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5使用网易的YUM源cd /etc/yum.repos.d/wget http://mirrors.163.com/.help/CentOS-Base-163.repo修改CentOS-Base-163.repo文件在所有mirrorlist前面加上#,把所有$releasever替换成5,保存。修改内容如下# 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-$releasever - Base - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osbaseurl=http://mirrors.163.com/centos/5/os/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #released updates [updates]name=CentOS-$releasever - Updates - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updatesbaseurl=http://mirrors.163.com/centos/5/updates/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #packages used/produced in the build but not released[addons]name=CentOS-$releasever - Addons - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addonsbaseurl=http://mirrors.163.com/centos/5/addons/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful[extras]name=CentOS-$releasever - Extras - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extrasbaseurl=http://mirrors.163.com/centos/5/extras/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plus - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplusbaseurl=http://mirrors.163.com/centos/5/centosplus/$basearch/gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #contrib - packages by Centos Users[contrib]name=CentOS-$releasever - Contrib - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contribbaseurl=http://mirrors.163.com/centos/5/contrib/$basearch/gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 上面红色部分为修改部分清理并重新生成YUM缓存Yum clean metadataYum makecache第三步: 此时的yum就正常工作了,我们可以用命令查看下      Yum list all