說明:此測(cè)試環(huán)境用Red Hat Enterprise Linux 5.4 作為測(cè)試機(jī),同理,本文理論上可以解決關(guān)于RHEL和CentOS 5版本甚至6版本的yum更新源的問題(其他版本未測(cè)試)
推薦使用鏡像源服務(wù)器網(wǎng)站:http://vault.centos.org/
問題描述:
1、RHEL的YUM源需要注冊(cè)用戶才能更新使用,由于CentOS和RHEL基本沒有區(qū)別,并且CentOS已經(jīng)被REHL收購(gòu)。所以將RHEL的YUM源替換為CentOS即可
2、CentOS 5 在2017-03-31日已經(jīng)結(jié)束支持,不再提供維護(hù)更新,所以包括阿里云鏡像站的文件可能都是過時(shí)或已經(jīng)有部分文件缺失
環(huán)境:Red Hat Enterprise Linux 5.4
解決方法:
1.清除原有RHEL的YUM及相關(guān)軟件包。
~]#? rpm -qa | grep yum | xargs rpm -e --nodeps
~]#? rpm -qa |grep python-urlgrabber|xargs rpm -e --nodeps
檢查yum是否刪除干凈
~]#rpm -qa |grep yum?
2.備份或只保留/etc/yum.repos.d/rhel-debuginfo.repo,其他.repo文件都刪掉,這里我選擇備份
~]# cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/rhel-debuginfo.repo.bak
3.將RHEL的yum源更換同版本的CentOS的yum源,修改baseurl和gpgkey為目標(biāo)鏡像服務(wù)器
baseurl=http://vault.centos.org/5.4/os/i386/
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
原RHEL的yum源:
修改為CentOS的yum源:
4.在安裝yum前,先下載相應(yīng)的rpm包
~]# wget http://vault.centos.org/5.4/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
~]# wget http://vault.centos.org/5.4/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
~]# wget http://vault.centos.org/5.4/os/i386/CentOS/yum-3.2.22-20.el5.centos.noarch.rpm
~]# wget http://vault.centos.org/5.4/os/i386/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
5.安裝yum軟件包
~]# rpm -ivh python-iniparse-0.2.3-4.el5.noarch.rpm
~]# rpm -ivh yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
~]# rpm -ivh yum-3.2.22-20.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
第三條命令一次安裝兩個(gè)rpm文件,因?yàn)樗麄兇嬖谝蕾囮P(guān)系,不在一起的話會(huì)安裝失敗。
6.更換yum源,使用http://vault.centos.org/作為更新源
將其中的baseurl中的$releasever之前部分替換成相應(yīng)歷史源站地址和版本號(hào)
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.? You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - 163.com
baseurl=http://vault.centos.org/5.4/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://vault.centos.org/5.4/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons - 163.com
baseurl=http://vault.centos.org/5.4/addons/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://vault.centos.org/5.4/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://vault.centos.org/5.4/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://vault.centos.org/5.4/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
7.確認(rèn)在 /etc/yum.repos.d/目錄沒有除了CentOS-Base.repo之外其他以repo結(jié)尾的文件,有的話刪除或做備份處理
8.yum更新和啟用更新源
~]# yum clean all
~]# yum makecache
過程出現(xiàn)time out 超時(shí)尋找其他mirror鏡像源,報(bào)錯(cuò),基本是下載資源和網(wǎng)速問題,可以退出安裝重新yum makecache
出現(xiàn)yum.pid報(bào)錯(cuò),刪掉重新makecache
~]# rm -r /var/run/yum.pid
~]# yun makecache
9.安裝完成,測(cè)試驗(yàn)證
~]# yum install telnet-server
"""
以上僅憑回憶操作所記,有問題后續(xù)測(cè)試更新
"""