今天想利用Yum下载一个mailx但是出现了很多奇怪的原因。出现“This system is not registered with RHN”的错误提示。出现这个错误的原因是你的Linux木有花钱在红帽网络上注册,所以无法下载,解决方案可以使用从Redhat演化而来的免费Linux版本CentOS,通过CentOS的yum更新源来实现RHEL5的YUM功能。下面结合文章写,但由于现在很多博客的CentOS5找不到对应的源,所以重新找了个源,所以很多都是重新引用。
虚拟机VM8
系统RHEL5.5 32位系统
利用源CentOS5.5的yum
1 check what yum package installed
查看RHEL是否安装了yum,若是安装了,那么又有哪些yum包:
[root@localhost ~]# rpm -qa |grep yum
yum-metadata-parser-1.0-8.fc6
yum-3.0.1-5.el5
yum-rhn-plugin-0.4.3-1.el5
yum-updatesd-3.0.1-5.el5
2 remove all installed yum packages
卸载上面显示的所有yum包:
[root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps(不检查依赖,直接删除rpm包)
再用
[root@localhost ~]# rpm -qa |grep yum
[root@localhost ~]#
查看,无信息显示表示已经卸载完成。
3 download the centos packages from website
[root@localhost ~]#wget http://vault.centos.org/5.5/os/i386/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm
[root@localhost ~]#wget http://vault.centos.org/5.5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
[root@localhost ~]#wget http://vault.centos.org/5.5/os/i386/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm
[root@localhost ~]#wget http://vault.centos.org/5.5/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
4 安装这所下载的四个包
注意:单个的安装包可能会依赖其它包(例如yum和yum-fastestmirror会相互依赖),所以我们可以把所有这些包放在一起,用一行命令将它们同时安装即可:
[root@localhost ~]# rpm -ivh yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm yum-3.2.22-26.el5.centos.noarch.rpm
5 download configure file
直接[root@localhost ~]# vi yum.repos.d/CentOS-Base.repo 添加以下内容:
[base]
name=CentOS-5 - Base
baseurl=http://vault.centos.org/5.5/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/5.5/os/i386/RPM-GPG-KEY-CentOS-5
#released updates
[update]
name=CentOS-5 - Updates
baseurl=http://vault.centos.org/5.5/updates/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/5.5/os/i386/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-5 - Addons
baseurl=http://vault.centos.org/5.5/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/5.5/os/i386/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-5 - Extras
baseurl=http://vault.centos.org/5.5/extras/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/5.5/os/i386/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5 - Plus
baseurl=http://vault.centos.org/5.5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/5.5/os/i386/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-5 - Contrib
baseurl=http://vault.centos.org/5.5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/5.5/os/i386/RPM-GPG-KEY-CentOS-5
6 [选做]clear cache and rebuild
[root@localhost ~]# yum clean metadata
Loaded plugins: fastestmirror
0 metadata files removed
0 sqlite files removed
0 metadata files removed
[root@localhost ~]# yum clean dbcache
Loaded plugins: fastestmirror
0 sqlite files removed
[root@localhost ~]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
addons | 1.9 kB 00:00
addons/filelists_db | 568 B 00:00
addons/other_db | 546 B 00:00
addons/primary_db | 1.1 kB 00:00
base | 1.1 kB 00:00
base/filelists | 3.6 MB 00:03
base/other | 13 MB 00:13
base/group | 1.1 MB 00:02
base/primary | 1.2 MB 00:01
extras | 2.1 kB 00:00
extras/filelists_db | 241 kB 00:00
extras/other_db | 406 kB 00:00
extras/group | 9.7 kB 00:00
extras/primary_db | 188 kB 00:00
update | 1.9 kB 00:00
update/filelists_db | 3.1 MB 00:03
update/other_db | 15 MB 00:15
update/primary_db | 634 kB 00:00
base 3641/3641
base 3641/3641
base 3641/3641
Metadata Cache Created
[root@localhost ~]#
7 installation has been completed, testing
//安装成功,开始测试:
[root@localhost ~]# yum update
借鉴,启发:https://blog.csdn.net/Ludwig_/article/details/52683926