首先说明,本文是我在网络上参考他人配置yum的过程后自己配置成功的一点分享,如发现有所雷同,雷同就对了,和别人有较大区别就有问题了。
我使用的系统是Redhat6.3.由于Redhat的yum被发行方认为是售后服务,需要收费,所以在此配置成centos6的yum。
一.卸载redhat内的yum
# rpm-aq|grep yum|xargs rpm -e --nodeps --删除yum
# cd /etc/yum.repos.d/ --进入yum的配置文件夹
# rm -rf rhel-source.repo rhel-source.repo.bak 删除文件夹内的redhat相关文件
二. 下载centos软件包
最重要的首先是查看自己redhat的系统是32位还是64位(笔者在此吃了大亏,操作了许多遍都不成功才发现自己是32位系统,而网上大多数博主分享的都是64位系统文件)
# arch --查看系统架构
i686 (出现i686)
I686说明是32位操作系统,163的下载网址中选择i386目录
x86 (32位)地址:http://mirrors.163.com/centos/6/os/i386/Packages/
x86_64 (64位)地址:http://mirrors.163.com/centos/6/os/x86_64/Packages/
然后再去下载centos软件包
wget (后根据系统架构选择目录,如笔者是32位系统)
#wget http://mirrors.163.com/centos/6/os/i386/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
#wget http://mirrors.163.com/centos/6/os/i386/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
#wget http://mirrors.163.com/centos/6/os/i386/Packages/yum-metadata-parser-1.1.2-16.el6.i686.rpm
#wget http://mirrors.163.com/centos/6/os/i386/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
#wget http://mirrors.163.com/centos/6/os/i386/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
(以上5个软件包均是笔者用到的,由于网上博主们分享的包更新后不存在了,笔者于2018/5/8在http://mirrors.163.com/centos/6/os/i386/Packages/ 网站中找到当前的最新版本使用,如若发现某些包已经不存在,即出现error:404 not found类似字样,请到网站中寻找最新包下载)
三.安装软件包
#rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
#rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm --replacefiles
(此处--replacefiles作一注解,此包下载是由于后面3个包需要此包版本达到3.9.1-10以上,而笔者系统已装的版本较旧,在安装后续包时弹出错误,故特下此包,但是安装此包时,又提示此包与已有包冲突,故加--replacefiles进行强制版本更替)
#rpm -ivh yum-metadata-parser-1.1.2-16.el6.i686.rpm
#rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
(此处为两个包同时安装,由于这两个包之间有依赖关系,故必须进行同时安装)
四.更改yum源
#cd /etc/yum.repos.d/ --进入yum文件夹
#wget http://mirrors.163.com/.help/CentOS6-Base-163.repo 下载配置文件
然后将此配置文件替换/etc/yum.repos.d同名文件
#sed -i "s;\$releasever;6;g" CentOS6-Base-163.repo
把$releasever替换成现有系统的版本号(6)(该命令是网上查询而来,有些人有用,有些人无用,笔者就没成功)
#vi 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
五.检测yum
执行yum repolist,如果显示出repo仓库列表,并显示软件包数量则OK。
(或者使用yum makecache)
使用yum安装软件包测试。
#yum -y install lrzsz
安装成功则yum可用。