1.rhel5系统安装的时候其实已经有yum了,刚安装redhat就可以在终端敲入yum,只是会提示没有注册
This system is not registered with RHN.
RHN support will be disabled.

只是因为如果用官方的网站更新的话除非你是用钱买的rhel5.否则它会提示注册之类的。
当然用[root@localhost Desktop]#yum update当然也是不行的
因此,我试着在网上找一些方法来实现yum自动更新,有的网站说利用CentOS的yum更新源,但需要删掉RedHat 5本来的yum,我先利用rpm -qa | grep yum找到所有yum文件,然后又用rpm -e命令删除RedHat 5本来的yum以后,发现网上给的CentOS的yum更新源无法连接上,于是我想恢复RedHat 5本来的yum,但怎么办?网上没有找到方法,于是我在光盘里面找,幸好我记得删除了哪几个文件,于是将删掉的文件又重新安装上去了,它们分别是:
yum-updatesd-3.0.1-5.el5.noarch.rpm
yum-security-1.0.4-3.el5.noarch.rpm
yum-rhn-plugin-0.5.2-3.el5.noarch.rpm
yum-metadata-parser-1.0-8.fc6.i386.rpm
yum-3.0.1-5.el5.noarch.rpm
注意安装的时候可能因为依赖项的问题,5个文件的安装有顺序性。
安装好以后在命令行敲入yum,终于有可以找到它了,呵呵
2. 修改源配置文件 gedit /etc/yum.repos.d/CentOS-Base.repo
在其中加入以下内容
[base]
name=CentOS-5-Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#released updates
[update]
name=CentOS-5-Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#packages used/produced in the build but not released
[addons]
name=CentOS-5-Addons
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons
baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that may be useful
[extras]
name=CentOS-5-Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5-Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#contrib - packages by Centos Users
[contrib]
name=CentOS-5-Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
# vi dag.repo
[dag]
name=Dag RPM Repository for RHEL5
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/
enabled=1
gpgcheck=1
gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt
3. 导入key
#rpm --import http://ftp.sjtu.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
4. 运行,测试
#yum install xmms-mp3
5.结果出现错误:
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
GPG key retrieval failed: [Errno 14] HTTP Error 404: Not Found
此时,将gpgcheck=1改成gpgcheck=0即可。
6. 运行,测试
#yum install xmms-mp3
能够正确安装上了