代码改变世界

RHEL 6.6配置网易CentOS镜像的yum源小结

2019-07-22 15:14  潇湘隐者  阅读(1892)  评论(0编辑  收藏  举报

 

   之前没有使用过网易CentOS镜像的yum源,最近由于需要,遂在一台测试服务器验证、测试了一下如何配置使用网易的Cent0S的yum源。此文仅仅是笔记性质,参考了网上大量资料(文末参考资料的相关链接)。

 

 

1: 删除RHEL 6.6原有的YUM相关包

 

[root@mytestlnx03 ~]# rpm -qa | grep yum
yum-plugin-security-1.1.30-30.el6.noarch
kabi-yum-plugins-1.0-2.el6.noarch
PackageKit-yum-0.5.8-23.el6.x86_64
yum-plugin-downloadonly-1.1.30-30.el6.noarch
yum-rhn-plugin-0.9.1-50.el6.noarch
yum-plugin-changelog-1.1.30-30.el6.noarch
yum-plugin-versionlock-1.1.30-30.el6.noarch
yum-3.2.29-60.el6.noarch
yum-presto-0.6.2-1.el6.noarch
yum-plugin-aliases-1.1.30-30.el6.noarch
PackageKit-yum-plugin-0.5.8-23.el6.x86_64
yum-utils-1.1.30-30.el6.noarch
yum-plugin-verify-1.1.30-30.el6.noarch
yum-plugin-tmprepo-1.1.30-30.el6.noarch
yum-metadata-parser-1.1.2-16.el6.x86_64
[root@mytestlnx03 ~]# rpm -qa | grep yum | xargs rpm -e --nodeps
warning: /etc/yum.conf saved as /etc/yum.conf.rpmsave
[root@mytestlnx03 ~]# rpm -qa | grep yum
[root@mytestlnx03 ~]# 

 

 

2:下载yum的相关安装包

 

 

注意:由于yum源一直在更新,所以有可能下面这些安装包已经不存在了(新的安装包给替换了),所以必须直接去网易的官方镜像验证确认,如果更新了,使用最新的安装包即可。http://mirrors.163.com/centos/6/os/x86_64/Packages/

 

 

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-urlgrabber-3.9.1-11.el6.noarch.rpm

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

 

 

网上有些资料还安装了其它yum相关包。这里测试发现这些包已经足够,当然测试也不充分,理解没有深入。仅仅是使用简单的功能

 

3:安装yum相关包以及依赖的包

 

 

[root@mytestlnx03 tmp]# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm 
warning: python-iniparse-0.3.1-2.1.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
        package python-iniparse-0.3.1-2.1.el6.noarch is already installed

 

安装python-urlgrabber与原来的python中的组件冲突,如下所示,之前卸载yum相关组件时,没有卸载python-urlgrabber-3.9.1-9.el6.noarch

 

[root@mytestlnx03 tmp]# rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm
warning: python-urlgrabber-3.9.1-11.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
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
[root@mytestlnx03 tmp]# rpm -qa|grep python-url
python-urlgrabber-3.9.1-9.el6.noarch
[root@mytestlnx03 tmp]# rpm -e --nodeps python-urlgrabber-3.9.1-9.el6.noarch
[root@mytestlnx03 tmp]# rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm
warning: python-urlgrabber-3.9.1-11.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:python-urlgrabber      ########################################### [100%]
 
 
[root@mytestlnx03 tmp]# rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm   yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
warning: yum-3.2.29-81.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:yum-metadata-parser    ########################################### [ 33%]
   2:yum-plugin-fastestmirro########################################### [ 67%]
   3:yum                    ########################################### [100%]

 

4:修改yumrepo配置文件

 

删除原yum的配置文件

 

[root@mytestlnx03 tmp]# cd /etc/yum.repos.d/
[root@mytestlnx03 yum.repos.d]# ls 
backup  redhat.repo  rhel-source.repo  server.repo
[root@mytestlnx03 yum.repos.d]# rm -rf *

 

下载repo文件,放在 /etc/yum.repos.d/下面

 

[root@mytestlnx03 yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
--2019-07-22 14:11:02--  http://mirrors.163.com/.help/CentOS6-Base-163.repo
Connecting to 192.168.27.92:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 2006 (2.0K) [application/octet-stream]
Saving to: “CentOS6-Base-163.repo”
 
100%[=================================================================================================>] 2,006       --.-K/s   in 0s      
 
2019-07-22 14:11:02 (73.2 MB/s) - “CentOS6-Base-163.repo” saved [2006/2006]
 
[root@mytestlnx03 yum.repos.d]# 

 

修改配置文件CentOS6-Base-163.repo:将baseurl中的$releasever修改为centos版本号,这里使用6替换,如下截图所示:

 

clip_image001

 

5:测试验证yum配置是否正确

 

[root@mytestlnx03 ~]# yum clean all

[root@mytestlnx03 ~]# yum list | grep ls

 

 

 

 

参考资料:

 

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

https://www.cnblogs.com/ssyfj/p/9172147.html

http://mirrors.163.com/centos/6/