1.为了方便起见,先切换到root用户

2.(可选)然后删除redhat原有的yum 
rpm -aq|grep yum|xargs rpm -e --nodeps 

3.下载yum安装文件
注意:最好自己到网站找找响应的包,这里列出来的可能会过时
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-22.el6.centos.noarch.rpm 
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm 
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-10.el6.noarch.rpm 
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
 
 
使用的是网易镜像,在这里可以找到你想要的,不一定要用centos的
 
 

 


4.进行安装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-22.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-10.el6.noarch.rpm
 
注意最后两个包必需同时安装,否则会相互依赖
 

5.将CentOS 6的repository的作为yum源

[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
enable=1
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6


#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
enable=1
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6


#packages used/produced in the build but not released
#[addons]
#name=CentOS-$releasever - Addons
#baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/
#gpgcheck=1
#gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6



#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
enable=1
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6


#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
gpgcheck=1
enabled=0

 
4.清除yum的缓存
   1. yum clean all
 
 
5.现在应该就可以用了
试试:
[root@CC ~]# yum makecache
Loaded plugins: fastestmirror, product-id, subscription-manager
Updating Red Hat repositories.
Determining fastest mirrors
base                                                     | 3.7 kB     00:00     
base/filelists_db                                        | 5.8 MB     01:08     
base/primary_db                                          | 4.5 MB     00:50     
base/other_db                                            | 2.6 MB     00:27     
base/group_gz                                            | 199 kB     00:02     
extras                                                   | 3.5 kB     00:00     
extras/filelists_db                                      | 2.7 kB     00:00     
extras/prestodelta                                       |  124 B     00:00     
extras/primary_db                                        | 6.3 kB     00:00     
extras/other_db                                          | 3.2 kB     00:00     
updates                                                  | 3.5 kB     00:00     
updates/filelists_db                                     | 1.7 MB     00:19     
updates/prestodelta                                      | 212 kB     00:02     
updates/primary_db                                       | 2.3 MB     00:25     
updates/other_db                                         | 239 kB     00:03     
Metadata Cache Created

 

另外,还有几个常用的源 

epel源:

[root@CACTI yum.repos.d]# cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=http://ftp.cuhk.edu.hk/pub/linux/fedora-epel/RPM-GPG-KEY-EPEL-6

[root@CACTI yum.repos.d]#

 

Rpmforge源:

[RPMFORGE]

 

name=redhat - $releasver - rpmforge

 

baseurl=http://apt.sw.be/redhat/el6/en/x86_64/rpmforge

 

enable=1

 

gpgcheck=0

 

本地源:

[root@CACTI yum.repos.d]# cat local.repo
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///mnt/rhel
enabled=1
gpgcheck=1
gpgkey=file:///mnt/rhel/RPM-GPG-KEY-redhat-release