RHEL是提供给企业使用的,虽然我们在网络上也能下载到它的镜像,但是我们无法使用它的服务。最近由于系统比较卡,重装了一次系统,装完之后,我用VMware Workstation Pro 12 加载了之前的RHEL 6.9-000002.vmdk文件之后居然发现不能挂载CD/DVD,这就不能愉快的玩了。在VMware的设置里折腾好久也没能搞定,光盘安装RPM包是没希望了,联想的最近学过的的YUM ,又重新燃起了希望。
Red Hat的yum在线更新是收费的,未注册则不能使用。既然无法使用RHEL的服务,那咱就给它换与它“一母同胞”的CentOS的YUM源,考虑到网速的原因,我选择了网易的源(http://mirrors.163.com/centos/6.9/os/x86_64/Packages/),接下来,开始我们的RHEL换源记。(下文所有操作以root用户执行)
1 准备
首先,我们需要先删除旧的的yum文件,保持一个纯净的安装环境,可以大大提高我们的成功率。
rpm -aq|grep yum|xargs rpm -e –nodeps
2下载RPM包文件
打开http://mirrors.163.com/centos/6.9/os/x86_64/Packages/点击即可手动下载(网上有许多通过wget方式下载,大家可以参考简单的方式来实现自己 的预定目标)
yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm yum-metadata-parser-1.1.2-16.el6.x86_64.rpm python-iniparse-0.3.1-2.1.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-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
执行到这步的时候出了一个坑,出现了如下提示
yum >= 3.0 is needed by yum-plugin-fastestmirror-1.1.30-40.el6.noarch
那就先yum-3.2.29-81.el6.centos.noarch.rpm 吧,但是,不幸的事情又发生了
yum-plugin-fastestmirror is needed by yum-3.2.29-81.el6.centos.noarch
它两不离不弃,却把我坑死了,回头一想,不让它检查依赖关系不就好了,果断实验一下,居然成功了。
rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm --force --nodeps rpm -ivh yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm --force --nodeps
4配置yum
<1>进入/etc/yum.repos.d/目录
cd /etc/yum.repos.d/
<2>清空
rm -rf *
<3>获取新的配置文件
wget http://mirrors.163.com/.help/CentOS6-base-163.repo
<4>修改配置文件
vim CentOS6-base-163.repo
给大家贴一份修改好的配置文件,大家可以把版本号修改一下,看看能不能正常运行,祝大家好运!
1 # CentOS-Base.repo 2 # 3 # The mirror system uses the connecting IP address of the client and the 4 # update status of each mirror to pick mirrors that are updated to and 5 # geographically close to the client. You should use this for CentOS updates 6 # unless you are manually picking other mirrors. 7 # 8 # If the mirrorlist= does not work for you, as a fall back you can try the 9 # remarked out baseurl= line instead. 10 # 11 # 12 [base] 13 name=CentOS-$releasever - Base - 163.com 14 baseurl=http://mirrors.163.com/centos/6.9/os/$basearch/ 15 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os 16 gpgcheck=1 17 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 18 #released updates 19 [updates] 20 name=CentOS-$releasever - Updates - 163.com 21 baseurl=http://mirrors.163.com/centos/6.9/updates/$basearch/ 22 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates 23 gpgcheck=1 24 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 25 #additional packages that may be useful 26 [extras] 27 name=CentOS-$releasever - Extras - 163.com 28 baseurl=http://mirrors.163.com/centos/6.9/extras/$basearch/ 29 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras 30 gpgcheck=1 31 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 32 #additional packages that extend functionality of existing packages 33 [centosplus] 34 name=CentOS-$releasever - Plus - 163.com 35 baseurl=http://mirrors.163.com/centos/6.9/centosplus/$basearch/ 36 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus 37 gpgcheck=1 38 enabled=0 39 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 40 #contrib - packages by Centos Users 41 [contrib] 42 name=CentOS-$releasever - Contrib - 163.com 43 baseurl=http://mirrors.163.com/centos/6.9/contrib/$basearch/ 44 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib 45 gpgcheck=1 46 enabled=0 47 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
5 测试
1.清理一下缓存:
yum clean all
2.做个本地缓存,搜索起来会快很多
yum makecache
3.列出已安装的软件包
yum list
如果前三步能够正常执行,那基本上已经配置好了,接下来就愉快的折腾吧!
4.享受一下劳动成果
yum update
RHEL6.9换源记到此已经结束喽,希望可以帮助到大家。本文还有诸多不足之处,望各位大佬多多指点!
本文参考了http://www.thinkphp.cn/topic/34712.html。
原创文章,作者:LinuxWalker,如若转载,请注明出处:http://www.178linux.com/81852