您的位置:首页 > 运维架构 > Linux

RHEL6.5使用CENTOS的YUM源

2014-06-03 09:05 525 查看
未注册的RHEL无法更新,出现This system is not registered with RHN,每次挂载本地源很麻烦,有些特殊的包本地源中还不一定有,一般都采用Centos的源进行替换。

解决方案主要包括两部分,一是卸载RHEL的YUM,安装同版本的CENTOS版YUM,二是设置yum的网络源,特别是加入国内的源以加快速度。

1.卸载

[plain] view
plaincopy





[root@localhost]# rpm -qa | grep yum  

PackageKit-yum-0.5.8-21.el6.x86_64  

yum-3.2.29-40.el6.noarch  

yum-utils-1.1.30-14.el6.noarch  

yum-plugin-security-1.1.30-14.el6.noarch  

yum-rhn-plugin-0.9.1-48.el6.noarch  

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

PackageKit-yum-plugin-0.5.8-21.el6.x86_64  

[root@localhost]# rpm -qa | grep yum| xargs rpm -e --nodeps  

[root@localhost]# yum install php  

bash: /usr/bin/yum: No such file or directory  

2.下载Centos的yum安装包

[plain] view
plaincopy





[root@localhost ~]#wget http://mirror.centos.org/centos-6/6.5/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm  

[root@localhost ~]# wget http://mirror.centos.org/centos-6/6.5/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm  

[root@localhost ~]# wget http://mirror.centos.org/centos-6/6.5/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm  

[root@localhost ~]# wget http://mirror.centos.org/centos-6/6.5/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm  

[root@localhos ~t]# wget http://mirror.centos.org/centos-6/6.5/os/x86_64/RPM-GPG-KEY-CentOS-6  

3.安装Centos的yum

[plain] view
plaincopy





[root@localhost ~]# 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 ~]# rpm --import RPM-GPG-KEY-CentOS-6  

  

[root@localhost ~]# rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm  

Preparing...                ########################################### [100%]  

   1:yum-metadata-parser    ########################################### [100%]  

[root@localhost ~]# rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm  

error: Failed dependencies:  

    yum-plugin-fastestmirror is needed by yum-3.2.29-40.el6.centos.noarch  

  

[root@localhost ~]# rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm  

Preparing...                ########################################### [100%]  

   1:yum-plugin-fastestmirro########################################### [ 50%]  

   2:yum                    ########################################### [100%]  

4.更新yum源

[plain] view
plaincopy





[root@localhost ~]# cd /etc/yum.repos.d/  

[root@localhost yum.repos.d]# ls  

local.repo  packagekit-media.repo  rhel-source.repo  

[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo  

--2014-05-17 16:36:38--  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: “CentOS6-Base-163.repo”  

  

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

  

2014-05-17 16:36:38 (98.0 KB/s) - “CentOS6-Base-163.repo” saved [2006/2006]  

需要将 CentOS6-Base-163.repo 文档中的$releasever占位符替换为本地系统的版本号6.5

本人用vi编辑,在末行模式下输入:%s/$releasever/6.5/g替换整个文件下的$releasever为6.5,替换成功后会提示15 次替换,共 15 行的字样,最后保存退出。

最后清除并重建缓存 yum clean all & yum makecache

[plain] view
plaincopy





[root@localhost yum.repos.d]# yum clean all  

Loaded plugins: fastestmirror, product-id, subscription-manager  

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.  

Cleaning repos: Local base extras updates  

Cleaning up Everything  

Cleaning up list of fastest mirrors  

[root@localhost 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.  

Determining fastest mirrors  

Local                                                    | 3.9 kB     00:00 ...   

Local/group_gz                                           | 204 kB     00:00 ...   

Local/filelists_db                                       | 3.8 MB     00:00 ...   

Local/primary_db                                         | 3.1 MB     00:00 ...   

Local/other_db                                           | 1.6 MB     00:00 ...   

base                                                     | 3.7 kB     00:00       

base/group_gz                                            | 220 kB     00:03       

base/filelists_db                                        | 5.9 MB     00:11       

base/primary_db                                          | 4.4 MB     00:10       

base/other_db                                            | 2.8 MB     00:04       

extras                                                   | 3.4 kB     00:00       

extras/filelists_db                                      |  11 kB     00:00       

extras/prestodelta                                       |  907 B     00:00       

extras/primary_db                                        |  19 kB     00:00       

extras/other_db                                          | 5.8 kB     00:00       

updates                                                  | 3.4 kB     00:00       

updates/filelists_db                                     | 1.9 MB     00:01       

updates/prestodelta                                      | 275 kB     00:00       

updates/primary_db                                       | 3.1 MB     00:02       

updates/other_db                                         |  26 MB     00:32       

Metadata Cache Created  

[root@localhost yum.repos.d]#   
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  转载