Redhat更换yum源

redhat 默认自带的 yum 源需要注册,才能更新,所以对于我们来说需要替换掉redhat的yum源。下文更换为网易的。

删除原有的yum

rpm -qa|grep yum|xargs rpm -e --nodeps

下载yum安装文件

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

[注] 下载时可能会找不到文件,登录http://mirrors.163.com/centos/6/os/x86_64/ 更换相应的文件。

安装

rpm -ivh python-iniparse-0.3.-2.1.el6.noarch.rpm

rpm -ivh yum-metadata-parser-1.1.-.el6.x86_64.rpm

rpm -ivh yum-3.2.-.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.-.el6.noarch.rpm

[注] 最后两个包需要同时安装,因为存在相互依赖

然而在执行最后一个安装命令时,出现了如下错误:

 [root@root test]# rpm -ivh yum-3.2.-.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.-.el6.noarch.rpm
warning: yum-3.2.-.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
python-urlgrabber >= 3.9.- is needed by yum-3.2.-.el6.centos.noarch

错误原因是缺少了3.9.1-10及以上版本的python-urlgrabber的依赖,所以从http://mirrors.163.com/centos/6/os/x86_64/ 寻找所需要的包。

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm

然后安装时又出错了:

 [root@root test]# rpm -ivh python-urlgrabber-3.9.-.el6.noarch.rpm
warning: python-urlgrabber-3.9.-.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [%]
file /usr/lib/python2./site-packages/urlgrabber/grabber.py from install of python-urlgrabber-3.9.-.el6.noarch conflicts with file from package python-urlgrabber-3.9.-.el6.noarch
file /usr/lib/python2./site-packages/urlgrabber/grabber.pyc from install of python-urlgrabber-3.9.-.el6.noarch conflicts with file from package python-urlgrabber-3.9.-.el6.noarch
file /usr/lib/python2./site-packages/urlgrabber/grabber.pyo from install of python-urlgrabber-3.9.-.el6.noarch conflicts with file from package python-urlgrabber-3.9.-.el6.noarch
file /usr/lib/python2./site-packages/urlgrabber/progress.pyc from install of python-urlgrabber-3.9.-.el6.noarch conflicts with file from package python-urlgrabber-3.9.-.el6.noarch
file /usr/lib/python2./site-packages/urlgrabber/progress.pyo from install of python-urlgrabber-3.9.-.el6.noarch conflicts with file from package python-urlgrabber-3.9.-.el6.noarch

与历史版本冲突了,在rpm安装的命令中加入--force 强制安装成功:

 [root@root test]# rpm -ivh --force python-urlgrabber-3.9.-.el6.noarch.rpm
warning: python-urlgrabber-3.9.-.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [%]
:python-urlgrabber ########################################### [%]

最后执行第三条安装命令成功:

 [root@root test]# rpm -ivh yum-3.2.-.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.-.el6.noarch.rpm
warning: yum-3.2.-.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [%]
:yum-plugin-fastestmirro########################################### [ %]
:yum ########################################### [%]

更换yum源

mv /etc/yum.repos.d/rhel-source.repo /etc/yum.repos.d/rhel-source.repo.bak

vim /etc/yum.repos.d/rhel-debuginfo.repo

内容为:

 [base]

 name=CentOS-$releasever - Base

 baseurl=http://mirrors.163.com/centos/6/os/$basearch/

 gpgcheck=

 gpgkey=http://mirrors.163.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6

 #released updates

 [updates]

 name=CentOS-$releasever - Updates

 baseurl=http://mirrors.163.com/centos/6/updates/$basearch/

 gpgcheck=

 gpgkey=http://mirrors.163.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6

 #packages used/produced in the build but not released

 #[addons]

 #name=CentOS-$releasever - Addons

 #baseurl=http://mirrors.163.com/centos/6/addons/$basearch/

 #gpgcheck=

 #gpgkey=http://mirrors.163.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6

 #additional packages that may be useful

 [extras]

 name=CentOS-$releasever - Extras

 baseurl=http://mirrors.163.com/centos/6/extras/$basearch/

 gpgcheck=

 gpgkey=http://mirrors.163.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6

 #additional packages that extend functionality of existing packages

 [centosplus]

 name=CentOS-$releasever - Plus

 baseurl=http://mirrors.163.com/centos/6./centosplus/$basearch/

 gpgcheck=

 enabled=

yum clean all 命令清除原有缓存,就成功了。

参考:

[1] redhat6.5 配置使用centos的yum源

[2] RHEL6配置yum源

上一篇:HTML5从iFrame调用父JavaScript函数的方法 – 除了使用postMessage之外?或PhoneGap应用程序的解决方案?


下一篇:Centos6下安装高版本Git