如何在RedHat 5.4上使用免费的YUM
      以前工作中一直使用centos系统,突然今天新装了RedHat 5.4系统,想用VIM工具可是新装系统大家都知道没有安装此工具,大家这时肯定都会想到使用YUM安装下就可以了,可是RedHat自带的YUM源,是在收费的情况下才能使用的。于是由于咱是小农阶级没办法GOOGLE下,原来这样的情况不是我一个遇到看来已经有很多的前辈了,于是我随便点开了几个链接。查看别人的劳动成果,看完后让我有点晕。方法太多试了好多最后终于搞定,也不容易呀。
      由于RedHat是自带的yum源是收费的,所以我们自然而然就想到了用他的社区版Centosyum源。所以首先我们要卸载RedHat自带的yumRPM包。
第一 步:
查看系统上安装的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.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 -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/
修改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=os
baseurl=http://mirrors.163.com/centos/5/os/$basearch/
gpgcheck=1
gpgkey=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=updates
baseurl=http://mirrors.163.com/centos/5/updates/$basearch/
gpgcheck=1
gpgkey=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=addons
baseurl=http://mirrors.163.com/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=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=extras
baseurl=http://mirrors.163.com/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=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=centosplus
baseurl=http://mirrors.163.com/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=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=contrib
baseurl=http://mirrors.163.com/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 
上面红色部分为修改部分
清理并重新生成YUM缓存
Yum clean metadata
Yum makecache
第三步:
此时的yum就正常工作了,我们可以用命令查看下
      Yum list all
      此时你时否看到你期待已久的画面。