自定义CentOS的yum升级源站点

来源:互联网 发布:java动物乐园代码 编辑:程序博客网 时间:2024/05/23 01:58

1、yum升级配置文件名: /etc/yum.repos.d/CentOS-Base.repo

 

2、编辑上述文件,把这个配置文件每个节所有以mirrorlist打头的设置全部用#注释掉

 

3、把原来baseurl打头用#注释掉的设置全打开(去掉#号)

 

4、查找替换"mirror.centos.org"为你想要的任何网站,我用的是上海交通大学的升级网站"ftp.sjtu.edu.cn"

 

5、经我改变的CENT OS 5.3的yum 升级配置文件如下:

 

# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# 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-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

 

6、补充说明1:配置文件最上面的一段英文的意思是说现在CentOS用了最新的升级机制,可以利用镜像站点列表为你找到最近的升级站点,也就是以mirrorlist开头的那些设置;但实际情况是我们可以利用baseurl这个设置直接指定你想要升级的站点。

 

7、补充说明2:配置文件中那些以$打头的字符串其实是变量,不需要像有些网上文章说的那样改成5、5.1或5.3什么的,也不用管是32位,还是64位的,这些变量和你的系统会自动匹配,所以直接查找替换掉服务器地址就可以了。