本文摘自:http://pengyl.blog.51cto.com/5591604/1271864


由于RHEL的yum在线更新是收费的,如果没有注册的话是不能使用的,即不能在线安装软件。在这种情况下,想使用RHEL系统,还想用yum源来在线安装软件,有没有办法?答案是有办法,请往下看!

1、删除RHEL原有的yum  
          rpm -aq|grep yum|xargs rpm -e --nodeps  #删除
2、下载新的yum安装包  #这里我们使用CentOS的yum源

      32bit下载地址;

http://mirror.centos.org/centos-6/6/os/i386/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

http://mirror.centos.org/centos-6/6/os/i386/Packages/yum-metadata-parser-1.1.2-16.el6.i686.rpm

http://mirror.centos.org/centos-6/6/os/i386/Packages/yum-3.2.29-40.el6.centos.noarch.rpm

http://mirror.centos.org/centos-6/6/os/i386/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

   64bit下载地址;

http://mirror.centos.org/centos-6/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

http://mirror.centos.org/centos-6/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

http://mirror.centos.org/centos-6/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

http://mirror.centos.org/centos-6/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm

在网址前加wget参数可以在linux命令行直接下载;

3、安装yum软件包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@localhost src] # rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
warning: python-iniparse-0.3.1-2.1.el6.noarch.rpm: Header V3 RSA /SHA256 Signature, key ID c105b9de: NOKEY
Preparing...                 ########################################### [100%]
package python-iniparse-0.3.1-2.1.el6.noarch is already installed
[root@localhost src] # rpm -ivh yum-metadata-parser-1.1.2-16.el6.i686.rpm
warning: yum-metadata-parser-1.1.2-16.el6.i686.rpm: Header V3 RSA /SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                 ########################################### [100%]
package yum-metadata-parser-1.1.2-16.el6.i686 is already installed
file /usr/lib/python2 .6 /site-packages/_sqlitecache .so from install of yum-metadata-parser-1.1.2-16.el6.i686 conflicts with file from package yum-metadata-parser-1.1.2-16.el6.i686
file /usr/lib/python2 .6 /site-packages/sqlitecachec .pyc from install of yum-metadata-parser-1.1.2-16.el6.i686 conflicts with file from package yum-metadata-parser-1.1.2-16.el6.i686
file /usr/lib/python2 .6 /site-packages/sqlitecachec .pyo from install of yum-metadata-parser-1.1.2-16.el6.i686 conflicts with file from package yum-metadata-parser-1.1.2-16.el6.i686
#注意:以下两个安装包要放在一起同时安装,否则会提示相互依赖,安装失败。
[root@localhost src] # rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
warning: yum-3.2.29-40.el6.centos.noarch.rpm: Header V3 RSA /SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                 ########################################### [100%]
file /etc/yum .conf from install of yum-3.2.29-40.el6.centos.noarch conflicts with file from package yum-3.2.29-30.el6.noarch
file /usr/lib/python2 .6 /site-packages/yum/__init__ .py from install of yum-3.2.29-40.el6.centos.noarch conflicts with file from package yum-3.2.29-30.el6.noarch
file /usr/lib/python2 .6 /site-packages/rpmUtils/__init__ .pyc from install of yum-3.2.29-40.el6.centos.noarch conflicts with file from package yum-3.2.29-30.el6.noarch
file /usr/lib/python2 .6 /site-packages/yum/__init__ .pyc from install of yum-3.2.29-40.el6.centos.noarch conflicts with file from package yum-3.2.29-30.el6.noarch
file /usr/lib/python2 .6 /site-packages/rpmUtils/__init__ .pyo from install of yum-3.2.29-40.el6.centos.noarch conflicts with file from package yum-3.2.29-30.el6.noarch
####省略类似此类信息######

4、更改yum源  #我们使用网易的CentOS镜像源

//

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
[root@localhost yum.repos.d]# wget  http: //mirrors.163.com/.help/CentOS6-Base-163.repo
-- 2013 - 08 - 13 17 : 41 : 36 --  http: //mirrors.163.com/.help/CentOS6-Base-163.repo
Resolving mirrors. 163 .com... 123.58 . 173.106
Connecting to mirrors. 163 .com| 123.58 . 173.106 |: 80 ... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2006 ( 2 .0K) [application/octet-stream]
Saving to: ?.entOS6-Base- 163 .repo?
100 %[==================================================>] 2 , 006 --.-K/s   in 0 .02s
2013 - 08 - 13 17 : 41 : 50 ( 112 KB/s) - ?.entOS6-Base- 163 .repo?.saved [ 2006 / 2006 ]
[root@localhost yum.repos.d]# ls
CentOS6-Base- 163 .repo  rhel-source.repo
[root@localhost yum.repos.d]# vi CentOS6-Base- 163 .repo
#把文件里面的$releasever全部替换为版本号,即 6 最后保存!
#全部替换使用: % s/$releasever/ 6 /g 替换后部分内容如下
[base]
name=CentOS- 6 - Base - 163 .com
baseurl=http: //mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http: //mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck= 1
gpgkey=http: //mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS- 6 - Updates - 163 .com
baseurl=http: //mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http: //mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
"CentOS6-Base-163.repo" 52L, 1856C
[root@localhost yum.repos.d]# yum clean all    #清除缓存
Loaded plugins: product-id, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Cleaning repos: base extras updates
Cleaning up Everything
[root@localhost yum.repos.d]# yum makecache #将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度
Loaded plugins: product-id, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
base                                                                 | 3.7 kB     00 : 00
base/group_gz                                                        | 209 kB     00 : 01
base/filelists_db                                                    | 4.9 MB     00 : 36
base/primary_db                                                      | 3.4 MB     00 : 20
base/other_db                                                        | 2.0 MB     00 : 17
extras                                                               | 3.5 kB     00 : 00
extras/filelists_db                                                  |   10 kB     00 : 00
extras/prestodelta                                                   |   953 B     00 : 00
extras/primary_db                                                    |   19 kB     00 : 00
extras/other_db                                                      | 5.5 kB     00 : 00
updates                                                              | 3.4 kB     00 : 00
updates/filelists_db                                                 | 3.1 MB     00 : 28
updates/prestodelta                                                  | 625 kB     00 : 03
updates/primary_db                                                   | 3.5 MB     00 : 21
updates/other_db                                                     | 412 kB     00 : 02
Metadata Cache Created
[root@localhost yum.repos.d]# yum install vim*  #测试
Loaded plugins: product-id, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Package 2 :vim-minimal- 7.2 . 411 - 1.8 .el6.i686 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package vim-X11.i686 2 : 7.2 . 411 - 1.8 .el6 will be installed
--> Processing Dependency: gtk2 >= 2.6 for package : 2 :vim-X11- 7.2 . 411 - 1.8 .el6.i686
--> Processing Dependency: perl(:MODULE_COMPAT_5. 10.1 ) for package : 2 :vim-X11- 7.2 . 411 - 1.8 .el6.i686