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.www58058.com/81852