本文参考:http://blog.itpub.net/23890223/viewspace-757724/

谢谢博主。。

系统环境:

系统版本:

[root@red-test yum.repos.d]# cat /etc/redhat-release 

Red Hat Enterprise Linux Server release 6.5 (Santiago)

内核版本:

[root@red-test yum.repos.d]# uname -rm

2.6.32-431.el6.x86_64 x86_64

我的是在上面的环境中测试的没有问题,如果大家按照我的这篇博文去做的话,请保证和我的环境保持一致。否则不能保证你按照我的步骤可以成功。


1、删除redhat原有的yum源:

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

2、下载新的yum安装包

这里我使用CentOS的yum源

mkdir /application/tools/ -p

cd /application/tools/ 

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

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

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

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


3、安装yum软件包

rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm 

rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm 

rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

注意:最后两个安装包要放在一起同时安装,否则会提示相互依赖,安装失败。


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

cd /etc/yum.repos.d/

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

vim CentOS6-Base-163.repo

编辑文件,把文件里面的$releasever全部替换为版本号,即6最后保存!

:%s/$releasever/6/g

操作完成后,记得wq保存退出。


5、清理yum缓存

yum clean all

yum makecache    #将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度

yum install vim*  #测试域名是否可用


到此为止,Redhat6可以使用CentOS的yum源在线安装软件了。



问题:

yum makecache时出现如下错误:

[root@red-test yum.repos.d]# yum makecache

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

http://mirrors.163.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.163.com/centos/6/os/x86_64/repodata/repomd.xml: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')

Trying other mirror.

Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

 出现这个不影响yum在线的安装使用


你直接yum install vim* 直接安装软件测试。只要能安装就可以使用了。。


希望你的也没有问题哦。。