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.1-2.1.el6.noarch.rpm

rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm

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

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

1 [root@root test]# rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm 
2 warning: yum-3.2.29-81.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
3 error: Failed dependencies:
4     python-urlgrabber >= 3.9.1-10 is needed by yum-3.2.29-81.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

然后安装时又出错了:

1 [root@root test]# rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm 
2 warning: python-urlgrabber-3.9.1-11.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
3 Preparing...                ########################################### [100%]
4     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
5     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
6     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
7     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
8     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

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

1 [root@root test]# rpm -ivh --force python-urlgrabber-3.9.1-11.el6.noarch.rpm 
2 warning: python-urlgrabber-3.9.1-11.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
3 Preparing...                ########################################### [100%]
4    1:python-urlgrabber      ########################################### [100%]

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

1 [root@root test]# rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm 
2 warning: yum-3.2.29-81.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
3 Preparing...                ########################################### [100%]
4    1:yum-plugin-fastestmirro########################################### [ 50%]
5    2:yum                    ########################################### [100%]

 

更换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

内容为:

 1 [base]
 2  
 3 name=CentOS-$releasever - Base
 4  
 5 baseurl=http://mirrors.163.com/centos/6/os/$basearch/
 6  
 7 gpgcheck=1
 8  
 9 gpgkey=http://mirrors.163.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6
10  
11 #released updates
12  
13 [updates]
14  
15 name=CentOS-$releasever - Updates
16  
17 baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
18  
19 gpgcheck=1
20  
21 gpgkey=http://mirrors.163.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6
22  
23 #packages used/produced in the build but not released
24  
25 #[addons]
26  
27 #name=CentOS-$releasever - Addons
28  
29 #baseurl=http://mirrors.163.com/centos/6/addons/$basearch/
30  
31 #gpgcheck=1
32  
33 #gpgkey=http://mirrors.163.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6
34  
35 #additional packages that may be useful
36  
37 [extras]
38  
39 name=CentOS-$releasever - Extras
40  
41 baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
42  
43 gpgcheck=1
44  
45 gpgkey=http://mirrors.163.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6
46  
47 #additional packages that extend functionality of existing packages
48  
49 [centosplus]
50  
51 name=CentOS-$releasever - Plus
52  
53 baseurl=http://mirrors.163.com/centos/6./centosplus/$basearch/
54  
55 gpgcheck=1
56  
57 enabled=0

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

 

参考:

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

[2] RHEL6配置yum源

上一篇:2021.10.04pm


下一篇:【单片机】CH32V103串口IDLE空闲中断