redhat6.5 更換centOS yum

開頭,我一定要吐槽下有些破環境...

 

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

 

經過一番研究,得出結論如果使用redhat的yum源是需要註冊付費的,作爲一名學生和初學者,我不想花錢羅,哈哈,當然有錢另說。總體思路非常簡單就是卸載原來所有yum的依賴包,然後配置使用centos的yum源。這裏需要注意的是每個人的環境和系統都不一樣,解決方法和一些細節都不盡相同,我們需要“隨機應變”,不要盲目照搬教程。

 

1.卸載RedHat原來的自帶的yum包

使用命令 rpm -qa|grep yum 能夠查看已經安裝的yum包。然後使用命令 rpm -qa|grep yum|xargs rpm -e --nodeps 不檢查依賴直接刪除所有的rpm包。最後再次用 rpm -qa|grep yum 命令查看,發現沒有任何顯示,則表示卸載成功。

 

2.下載新的centos的yum包,然後安裝

首先你得先弄清楚自己的系統版本號和系統位數,使用命令 cat /etc/issue && arch 查看,如果是i386或者i686就是32位的,如果是x86_64就是64位的。

然後到http://mirrors.kernel.org/centos/ 或者 http://mirrors.163.com/centos/ 找對應系統版本號和系統位數下載,找到yum、yum-plugin-fastestmirror、yum-metadata-parser、python-urlgrabber這四個軟件包下載。

最後使用命令安裝

rpm -ivh yum-metadata-parser-1.1.2.16.el6.rpm

rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm  yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm  python-urlgrabber-3.9.1-11.el6.noarch.rpm (把相互依賴的包一起安裝)

在安裝過程中因爲環境不一樣可能出現不同的問題。如果是因爲缺少依賴包安裝失敗會出現 error:Failed  dependencies:缺失包 is needed by 你安裝的包,這種情況下,你需要下載缺失的包,然後一起安裝即可。如果是因爲你安裝的包已經存在但是版本不一樣會出現conflicts with的提示,你需要根據提示把原來的包卸載之後再次安裝新的包。

有些包不好找,到ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.5/x86_64/updates/security/這裏找找

3.更換yum源,使用163的源

打開http://mirrors.163.com/.help/centos.html,在裏面下載對應版本的repo文件,比如我下載的是CentOS6-Base-163.repo文件,然後把它放到/etc/yum.repos.d/下。還需要打開CentOS6-Base-163.repo文件修改$releasever爲版本號6

已經修改後的文件內容如下:

 

# 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-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6


#released updates 
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6


#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6


#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6


#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

4.清除原有緩存

使用命令 yum clean all 清除原來的緩存。

 

5.重新建立緩存

 使用命令 yum makecache 重建緩存。

 

 

 

轉載鏈接:

https://blog.csdn.net/u012038649/article/details/68950785

https://blog.csdn.net/dujianxiong/article/details/78481912

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章