##引言##:由于RHEL的yum在线更新是收费的,如果没有注册的话是不能使用的,即不能在线安装软件。那么要想用yum在线安装软件我们可以使用centos的yum源,具体办法见下面内容。
一、删除RHEL原有的yum
[root@localhost ~]# rpm -aq|grep yum|xargs rpm -e --nodeps ##删除
二、下载centos的yum安装包
[root@localhost ~]# wget http://vault.centos.org/6.0/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
[root@localhost ~]# wget http://vault.centos.org/6.0/os/x86_64/Packages/yum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm
[root@localhost ~]# wget http://vault.centos.org/6.0/os/x86_64/Packages/yum-3.2.27-14.el6.centos.noarch.rpm
[root@localhost ~]# wget http://vault.centos.org/6.0/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm
三、安装yum软件包
[root@localhost ~]# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
[root@localhost ~]# rpm -ivh yum-metadata-parser-1.1.2-14.1.el6.i686.rpm
####注意下面这两个软件包必须一起安装####
[root@localhost ~]# rpm -ivh yum-3.2.27-14.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm
四、更改本地yum源,使用网易的Centos,yum源
[root@localhost ~]# cd /etc/yum.repos.d/ ##切换到yum源配置目录
####下载网易yum源
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
[root@localhost yum.repos.d]# vi CentOS6-Base-163.repo ##使用vi编辑yum配置文件将文件中$releasever的替换成6。在末行模式执行此命令括号中的命令(:% s/$releasever/6/g)共替换15处。
五、清除yum缓存
[root@localhost yum.repos.d]# yum clean all ##清除缓存
[root@localhost yum.repos.d]# yum makecache ##将服务器上的软件包缓存到本地
[root@localhost yum.repos.d]# yum -y install httpd ##测试安装httpd服务
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
--> Processing Dependency: httpd = 2.2.15-29.el6_4 for package: httpd-devel-2.2.15-29.el6_4.x86_64
---> Package httpd.x86_64 0:2.2.15-39.el6.centos set to be updated
--> Processing Dependency: httpd-tools = 2.2.15-39.el6.centos for package: httpd-2.2.15-39.el6.centos.x86_64
--> Running transaction check
---> Package httpd-devel.x86_64 0:2.2.15-39.el6.centos set to be updated
---> Package httpd-tools.x86_64 0:2.2.15-39.el6.centos set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================
Updating:
httpd x86_64 2.2.15-39.el6.centos base 825 k
Updating for dependencies:
httpd-devel x86_64 2.2.15-39.el6.centos base 152 k
httpd-tools x86_64 2.2.15-39.el6.centos base 75 k
Transaction Summary
======================================================================================================================================
Install 0 Package(s)
Upgrade 3 Package(s)
Total download size: 1.0 M
Downloading Packages:
(1/3): httpd-2.2.15-39.el6.centos.x86_64.rpm | 825 kB 00:02
(2/3): httpd-devel-2.2.15-39.el6.centos.x86_64.rpm | 152 kB 00:00
(3/3): httpd-tools-2.2.15-39.el6.centos.x86_64.rpm | 75 kB 00:00
--------------------------------------------------------------------------------------------------------------------------------------
Total 277 kB/s | 1.0 MB 00:03
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
base/gpgkey | 3.3 kB 00:00 ...
Importing GPG key 0xC105B9DE "CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>" from http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
PackageKit-0.5.8-21.el6.x86_64 has missing requires of PackageKit-yum = (‘0‘, ‘0.5.8‘, ‘21.el6‘)
PackageKit-0.5.8-21.el6.x86_64 has missing requires of PackageKit-yum-plugin = (‘0‘, ‘0.5.8‘, ‘21.el6‘)
rhn-check-1.0.0.1-16.el6.noarch has missing requires of yum-rhn-plugin >= (‘0‘, ‘0.9.1‘, ‘35‘)
Updating : httpd-tools-2.2.15-39.el6.centos.x86_64 1/6
Updating : httpd-2.2.15-39.el6.centos.x86_64 2/6
Updating : httpd-devel-2.2.15-39.el6.centos.x86_64 3/6
Cleanup : httpd-devel-2.2.15-29.el6_4.x86_64 4/6
Cleanup : httpd-2.2.15-29.el6_4.x86_64 5/6
Cleanup : httpd-tools-2.2.15-29.el6_4.x86_64 6/6
Updated:
httpd.x86_64 0:2.2.15-39.el6.centos
Dependency Updated:
httpd-devel.x86_64 0:2.2.15-39.el6.centos httpd-tools.x86_64 0:2.2.15-39.el6.centos
Complete!
#########至此RHEL的yum就更改为Centos的yum源##########
本文出自 “Linux” 博客,请务必保留此出处http://wangenzhi.blog.51cto.com/9214174/1671110
原文地址:http://wangenzhi.blog.51cto.com/9214174/1671110