您的位置:首页 > 其它

RHEL6更换yum源

2013-07-22 20:10 190 查看
由于 redhat的yum在线更新是收费的,如果没有注册的话就不能从redhat仓库中进行更新,如果要使用在线更新功能,则需将redhat自带的yum卸载后,重新安装,再配置centos的yum源,以下为详细过程:

1、删除redhat原有的yum

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

2、下载yum所需要的安装包(其中XXX表示版本号)
yum-XXX.el6.centos.noarch.rpm
yum-metadata-parser-XXX.el6.x86_64.rpm
yum-plugin-fastestmirror-XXX.el6.noarch.rpm
python-iniparse-XXX.el6.noarch.rpm
有关这些包的下载地址,我们可以使用centos官方提供的镜像源(http://mirror.centos.org/),也可以使用网易提供的镜像源(http://mirrors.163.com/),针对于国内用户来说,使用网易的镜像源速度相对快一些。

第一步:首先打开网易镜像首页(http://mirrors.163.com/ ),这里我们选择centos-6这个版本,对于其他版本的redhat最好选择与其发行版本号一致的centos源

这里我们使用centos,打开链接

下面有好几个版本,我们这里使用6这个版本(如果小版本号中下面没有东西之后我们可以统一使用6这个来替代)

os下存在着我们所需要的文件

32位请选择i386,64位请选择x86_64

Packages下就是所有包的地址,从这里选择相应的包进行下载

第二步:下载所需要的rpm包,这里我们下载如下几个包(版本号可能会有不一致)

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-30.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-14.el6.noarch.rpm


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


3、安装yum所需要的软件包

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-30.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

注意:最后两个安装包要放在一起同时安装,否则会提示相互依赖,安装失败。

4、更改yum源

cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
vi CentOS6-Base-163.repo

把文件里面的$releasever全部替换为版本号,这里我们使用版本6(即把$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


5、清理yum缓存

yum clean all
yum makecache


到此为止,更改redhat更换yum源的操作就完成了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: