1. 程式人生 > >Redhat6.5更改yum源

Redhat6.5更改yum源

redhat預設自帶的yum源需要註冊,才能更新,報錯:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

今天試了一下,替換為centos對應的源。

先看了一下yum所有的包,其中提供yum命令的是yum-3.2.29-81.el6.centos.noarch包。

[[email protected] ~]# rpm -qf /usr/bin/yum
yum-3.2.29-81.el6.centos.noarch

網上說只刪除subscription-manager這個包就可以了,本次沒有驗證。本次是把yum和subscription-manager包同時刪除了,順便試試自己能否修復。^^

[[email protected] ~]# rpm -e yum
error: Failed dependencies:
	yum is needed by (installed) rhn-client-tools-1.0.0.1-16.el6.noarch
	yum >= 3.0 is needed by (installed) PackageKit-yum-plugin-0.5.8-21.el6.x86_64
	yum >= 3.2.19 is needed by (installed) PackageKit-yum-0.5.8-21.el6.x86_64
	yum >= 3.2.19-15 is needed by (installed) yum-rhn-plugin-0.9.1-48.el6.noarch
	yum is needed by (installed) python-meh-0.12.1-3.el6.noarch
	yum >= 3.2.19-15 is needed by (installed) subscription-manager-1.9.11-1.el6.x86_64
	yum >= 3.2.18 is needed by (installed) yum-plugin-security-1.1.30-14.el6.noarch
	yum >= 3.2.29 is needed by (installed) yum-utils-1.1.30-14.el6.noarch
[
[email protected]
~]# rpm -e subscription-manager error: Failed dependencies: subscription-manager = 1.9.11-1.el6 is needed by (installed) subscription-manager-gui-1.9.11-1.el6.x86_64
[[email protected] ~]# rpm -e yum --nodeps

各種依賴關係,只能強制刪除yum了,刪除之後再測試,果然沒有yum命令了。

[[email protected] ~]# yum repolist
-bash: /usr/bin/yum: No such file or directory

對於subscription-manager,簡單粗暴的一刪到底。對不起了,redhat……^^

[[email protected] ~]# rpm -e subscription-manager
error: Failed dependencies:
	subscription-manager = 1.9.11-1.el6 is needed by (installed) subscription-manager-gui-1.9.11-1.el6.x86_64
You have new mail in /var/spool/mail/root
[[email protected] ~]# rpm -e subscription-manager-gui-1.9.11-1.el6.x86_64
error: Failed dependencies:
	subscription-manager-gui = 1.9.11-1.el6 is needed by (installed) subscription-manager-firstboot-1.9.11-1.el6.x86_64
[[email protected] ~]# rpm -e subscription-manager-firstboot-1.9.11-1.el6.x86_64
[[email protected] ~]# rpm -e subscription-manager-gui-1.9.11-1.el6.x86_64
You have new mail in /var/spool/mail/root
[[email protected] ~]# rpm -e subscription-manager
You have new mail in /var/spool/mail/root

都刪完了就開始安裝了。我選擇上163映象源下載軟體包。

http://mirrors.163.com/centos/6/os/x86_64/Packages/

yum相關的包很多,只有yum-3.2.29-81.el6.centos.noarch.rpm是主程式包,我把它下載下來,通過xftp或者xshell自帶的ftp工具傳到centos6.5系統上。


chmod修改許可權之後,檢查依賴關係,發現還需要python-urlgrabber和yum-plugin-fastestmirror包,同時需要KEY。

[[email protected] ~]# rpm -ivh --test yum-3.2.29-81.el6.centos.noarch.rpm 
warning: yum-3.2.29-81.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
	python-urlgrabber >= 3.9.1-10 is needed by yum-3.2.29-81.el6.centos.noarch
	yum-plugin-fastestmirror is needed by yum-3.2.29-81.el6.centos.noarch
You have new mail in /var/spool/mail/root

在http://mirrors.163.com/centos/6/os/x86_64 的頁面下載RPM-GPG-KEY-CentOS-6檔案,傳到伺服器上,並匯入作業系統。

[[email protected] ~]# rpm --import RPM-GPG-KEY-CentOS-6

下載python-urlgrabber和yum-plugin-fastestmirror包。開始安裝,結果新下載的包與系統已經安裝的包衝突,那就強制解除安裝掉。

[[email protected] ~]# rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm 
Preparing...                ########################################### [100%]
	file /usr/lib/python2.6/site-packages/urlgrabber/grabber.py from install of python-urlgrabber-3.9.1-11.el6.noarch conflicts with file from package python-urlgrabber-3.9.1-9.el6.noarch
	file /usr/lib/python2.6/site-packages/urlgrabber/grabber.pyc from install of python-urlgrabber-3.9.1-11.el6.noarch conflicts with file from package python-urlgrabber-3.9.1-9.el6.noarch
	file /usr/lib/python2.6/site-packages/urlgrabber/grabber.pyo from install of python-urlgrabber-3.9.1-11.el6.noarch conflicts with file from package python-urlgrabber-3.9.1-9.el6.noarch
	file /usr/lib/python2.6/site-packages/urlgrabber/progress.pyc from install of python-urlgrabber-3.9.1-11.el6.noarch conflicts with file from package python-urlgrabber-3.9.1-9.el6.noarch
	file /usr/lib/python2.6/site-packages/urlgrabber/progress.pyo from install of python-urlgrabber-3.9.1-11.el6.noarch conflicts with file from package python-urlgrabber-3.9.1-9.el6.noarch
You have new mail in /var/spool/mail/root
[[email protected] ~]# rpm -e python-urlgrabber-3.9.1-9.el6.noarch
error: Failed dependencies:
	urlgrabber is needed by (installed) python-virtinst-0.600.0-18.el6.noarch
	python-urlgrabber is needed by (installed) python-virtinst-0.600.0-18.el6.noarch
[[email protected] ~]# rpm -e python-urlgrabber-3.9.1-9.el6.noarch --nodeps
You have new mail in /var/spool/mail/root

然後重新安裝,成功。

[[email protected] ~]# rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm 
Preparing...                ########################################### [100%]
   1:python-urlgrabber      ########################################### [100%]
安裝yum-plugin-fastestmirror包,發現它與yum包互為依賴,同時安裝就好了。

[[email protected] ~]# rpm -ivh yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm 
error: Failed dependencies:
	yum >= 3.0 is needed by yum-plugin-fastestmirror-1.1.30-40.el6.noarch
[[email protected] ~]# rpm -ivh yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm yum-3.2.29-81.el6.centos.noarch.rpm 
Preparing...                ########################################### [100%]
   1:yum                    ########################################### [ 50%]
   2:yum-plugin-fastestmirro########################################### [100%]

最後試試yum,沒問題了。