redhat无法注册RHN的解决办法

1.问题

初学Linux,采用边实战nginx边学Linux命令的方式,这样学习的还快还真实一些.当然,问题来的很快.我使用的是redhat,安装pcre就出现了问题,如下:

 1 [root@localhost ~]# yum install pcre
 2 Loading "security" plugin
 3 Loading "installonlyn" plugin
 4 Loading "rhnplugin" plugin
 5 This system is not registered with RHN.
 6 RHN support will be disabled.
 7 Setting up Install Process
 8 Setting up repositories
 9 No Repositories Available to Set Up
10 Reading repository metadata in from local files
11 Parsing package install arguments
12 Setting up repositories
13 No Repositories Available to Set Up
14 Reading repository metadata in from local files
15 No Match for argument: pcre
16 Nothing to do

 从5-6行的描述来看,系统还没有注册RHN.网上查了一下整理到这里,当然你经过本人测试过的.大致过程是重新安装CentOS的yum,卸载Redhat的.好吧,继续

2.解决问题过程

1)查看redhat版本.

不同的redhat版本安装的yum不同,所以在这里需要先知道linux的版本.使用命令

1 cat /etc/issue

我的Linux版本为:

1 Red Hat Enterprise Linux Server release 5.1 (Tikanga)
2 Kernel 
 on an m

2)卸载yum.

1 rpm -qa|grep yum|xargs rpm -e --nodeps

执行后等待,后不会有任何提示,不过可以使用命令

1 rpm -qa|grep yum

在卸载前后查看一下yum就可以对比得出,卸载是否有效.

3)安装yum.

http://mirrors.ustc.edu.cn/centos/(网址可能会发生变化,请网上找最新的版本)找到对应版本的RPM包,进入http://mirrors.ustc.edu.cn/centos/5.1/readme,内容是:

1 This directory (and version of CentOS) is depreciated.  For normal users,
2 you should use /5/ and not /5.1/ in your path. Please see this FAQ
3 concerning the CentOS release scheme:
4 
5 http://www.centos.org/modules/smartfaq/faq.php?faqid=34
6 
7 If you know what you are doing, and absolutely want to remain at the 5.1
8 level, go to http://vault.centos.org/ for packages.

大致的意思是使用centos5的版本即可.根据32位还是64位执行不同的命令下载即可.

CentOS5
32位版的:
wget http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/python-iniparse-0.2.3-6.el5.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm
wget http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
64位版的:
wget http://mirrors.ustc.edu.cn/centos/5/os/x86_64/CentOS/python-iniparse-0.2.3-6.el5.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-4.el5.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm

下载完成,执行结果如下:

 1 [root@localhost ~]# wget http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/python-iniparse-0.2.3-6.el5.noarch.rpm
 2 wget http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
 3 wget http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm
 4 wget http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm--23:31:13--  http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/python-iniparse-0.2.3-6.el5.noarch.rpm
 5 Resolving mirrors.ustc.edu.cn... 202.141.160.110, 2001:da8:d800:95::110
 6 Connecting to mirrors.ustc.edu.cn|202.141.160.110|:80... connected.
 7 HTTP request sent, awaiting response... 200 OK
 8 Length: 34330 (34K) [application/x-redhat-package-manager]
 9 Saving to: `python-iniparse-0.2.3-6.el5.noarch.rpm'
10 
11 100%[==========================================================================>] 34,330       222K/s   in 0.2s   
12 
13 23:31:13 (222 KB/s) - `python-iniparse-0.2.3-6.el5.noarch.rpm' saved [34330/34330]
14 
15 [root@localhost ~]# wget http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
16 --23:31:13--  http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
17 Resolving mirrors.ustc.edu.cn... 202.141.160.110, 2001:da8:d800:95::110
18 Connecting to mirrors.ustc.edu.cn|202.141.160.110|:80... connected.
19 HTTP request sent, awaiting response... 200 OK
20 Length: 1034960 (1011K) [application/x-redhat-package-manager]
21 Saving to: `yum-3.2.22-40.el5.centos.noarch.rpm'
22 
23 100%[==========================================================================>] 1,034,960    410K/s   in 2.5s   
24 
25 23:31:16 (410 KB/s) - `yum-3.2.22-40.el5.centos.noarch.rpm' saved [1034960/1034960]
26 
27 [root@localhost ~]# wget http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm
28 --23:31:16--  http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm
29 Resolving mirrors.ustc.edu.cn... 202.141.160.110, 2001:da8:d800:95::110
30 Connecting to mirrors.ustc.edu.cn|202.141.160.110|:80... connected.
31 HTTP request sent, awaiting response... 200 OK
32 Length: 26164 (26K) [application/x-redhat-package-manager]
33 Saving to: `yum-metadata-parser-1.1.2-4.el5.i386.rpm'
34 
35 100%[==========================================================================>] 26,164       125K/s   in 0.2s   
36 
37 23:31:16 (125 KB/s) - `yum-metadata-parser-1.1.2-4.el5.i386.rpm' saved [26164/26164]
38 
39 [root@localhost ~]# wget http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm--23:31:25--  http://mirrors.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
40 Resolving mirrors.ustc.edu.cn... 202.141.160.110, 2001:da8:d800:95::110
41 Connecting to mirrors.ustc.edu.cn|202.141.160.110|:80... connected.
42 HTTP request sent, awaiting response... 200 OK
43 Length: 21033 (21K) [application/x-redhat-package-manager]
44 Saving to: `yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm'
45 
46 100%[===========================================================================================>] 21,033      --.-K/s   in 0.1s   
47 
48 23:31:26 (183 KB/s) - `yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm' saved [21033/21033]
View Code

安装顺序如下:

1 rpm -ivh python-iniparse-0.2.3-6.el5.noarch.rpm 
2 rpm -ivh yum-metadata-parser-1.1.2-4.el5.i386.rpm 
3 rpm -ivh yum-3.2.22-40.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm

 执行结果如下:

 1 [root@localhost ~]# rpm -ivh python-iniparse-0.2.3-6.el5.noarch.rpm 
 2 warning: python-iniparse-0.2.3-6.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
 3 Preparing...                ########################################### [100%]
 4    1:python-iniparse        ########################################### [100%]
 5 [root@localhost ~]# rpm -ivh yum-metadata-parser-1.1.2-4.el5.i386.rpm 
 6 warning: yum-metadata-parser-1.1.2-4.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
 7 Preparing...                ########################################### [100%]
 8    1:yum-metadata-parser    ########################################### [100%]
 9 [root@localhost ~]# rpm -ivh yum-3.2.22-40.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
10 warning: yum-3.2.22-40.el5.centos.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
11 Preparing...                ########################################### [100%]
12    1:yum-fastestmirror      ########################################### [ 50%]
13    2:yum                    ########################################### [100%]
View Code

4)下载yum配置源.

1 mv rhel-debuginfo.repo rhel-debuginfo.repo.bak
2 cd /etc/yum.repos.d
3 wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo

5)生成缓存.

执行命令:

1 yum makecache

执行结果:

 1 Loaded plugins: fastestmirror
 2 Loading mirror speeds from cached hostfile
 3 addons                    100% |=========================| 1.9 kB    00:00     
 4 addons/filelists_db       100% |=========================|  574 B    00:00     
 5 addons/other_db           100% |=========================|  550 B    00:00     
 6 addons/primary_db         100% |=========================| 1.1 kB    00:00     
 7 base                      100% |=========================| 1.1 kB    00:00     
 8 base/filelists            100% |=========================| 3.1 MB    00:06     
 9 base/other                100% |=========================|  11 MB    00:32     
10 base/group                100% |=========================| 1.1 MB    00:07     
11 base/primary              100% |=========================| 995 kB    00:02     
12 extras                    100% |=========================| 2.1 kB    00:00     
13 extras/filelists_db       100% |=========================| 211 kB    00:01     
14 extras/other_db           100% |=========================| 431 kB    00:01     
15 extras/group              100% |=========================| 9.7 kB    00:00     
16 extras/primary_db         100% |=========================| 164 kB    00:00     
17 update                    100% |=========================| 1.9 kB    00:00     
18 update/filelists_db       100% |=========================| 858 kB    00:02     
19 update/other_db           100% |=========================| 4.7 MB    00:26     
20 update/primary_db         100% |=========================| 173 kB    00:02     
21 base                                                                  2789/2789
22 base                                                                  2789/2789
23 base                                                                  2789/2789
24 Metadata Cache Created
View Code

完成.

原文地址:https://www.cnblogs.com/geyifan/p/3473883.html