RHEL 6.5 X86_64配置CentOS yum源

1、背景说明

刀片服务器GEN9无法通过引导方式安装CentOS,只能进行RHEL的安装。而RHEL上的yum源只能注册账户才能使用,故需要进行yum源替换

2、步骤

1、删除rhel自带的yum源
rpm -qa|grep yum|xargs rpm -e --nodeps
rpm -qa |grep yum

2、下载新的yum安装包
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-3.2.29-69.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
 
友情提醒:这些rpm包小版本号会变更,所有复制此链接时,如果报404错误,请登入此网页并查看具体小版本号

注意:很多网上提供的镜像源中所涉及的
yum-3.2.29-69.el6.centos.noarch.rpm此安装包已经没有了
mirrors中提供的包为
yum-3.2.29-81.el6.centos.noarch.rpm
如果对此yum安装包进行下载安装的话,它会依赖于一些python的包,
python-urlgrabber >= 3.9.1-10 is needed by yum-3.2.29-81.el6.centos.noarch

python版本需要为2.7以上,并不是自带的版本

所以这里我单独去下载了一个就版本,实测是可以的
我使用的版本为:yum-3.2.29-30.el6.noarch.rpm

3、安装yum包,有依赖关系,三个一起安装
rpm -ivh yum-3.2.29-30.el6.noarch.rpm yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm 
warning: yum-3.2.29-30.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
warning: yum-metadata-parser-1.1.2-16.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:yum-metadata-parser    ########################################### [ 33%]
   2:yum                    ########################################### [ 67%]
   3:yum-plugin-fastestmirro########################################### [100%]

4、将rhel自带的yum仓库文件移走
yum.repos.d]# mkdir bak
yum.repos.d]# mv mirrors-rpmforge* bak/
yum.repos.d]# mv rh* bak/
yum.repos.d]# ls
bak                    epel.repo          packagekit-media.repo
CentOS6-Base-163.repo  epel-testing.repo  rpmforge.repo
yum.repos.d]# mv packagekit-media.repo bak/

5、更改163的yum源
yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
    --2017-04-11 02:23:41--  http://mirrors.163.com/.help/CentOS6-Base-163.repo
Resolving mirrors.163.com... 123.58.173.185, 123.58.173.186
Connecting to mirrors.163.com|123.58.173.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2006 (2.0K) [application/octet-stream]
Saving to: “CentOS6-Base-163.repo”

100%[================================================>] 2,006       --.-K/s   in 0s      

2017-04-11 02:23:41 (219 MB/s) - “CentOS6-Base-163.repo” saved [2006/2006]

替换$releaserver全部替换为版本号
yum.repos.d]#  sed -i 's#$releasever#6#g' CentOS6-Base-163.repo

6、yum仓库确认
yum.repos.d]# yum repolist
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
repo id                                                                                                 repo name                                                                                                                     status
base                                                                                                    CentOS-6 - Base - 163.com                                                                                                     6,706
extras                                                                                                  CentOS-6 - Extras - 163.com                                                                                                      64
updates                                                                                                 CentOS-6 - Updates - 163.com                                                                                                     32
repolist: 6,802