您的位置:首页 > 运维架构 > Linux

配置CentOS6 yum源

2017-06-02 09:59 204 查看
Centos 有个很方便的软件安装工具  yum,但是默认安装完centos,系统里使用的是国外的centos更新源,这就造成了我们使用默认更新源安装或者更新软件时速度很慢的问题。
为了使用yum工具能快速的安装更新软件,我们需要将默认的yum更新源配置为国内的更新源。yum更新源配置文件位于centos目录  /etc/yum.repos.d/  下。

首先提供几个国内快速的更新源:

教育网资源:

1 上海交大: http://ftp.sjtu.edu.cn/centos/
服务器位于北京,中国教育网网络中心,下载速度高达十M。

北方用户与教育网用户推荐,速度飞快。

2 中国科技大学:http://centos.ustc.edu.cn

服务器位于合肥。 南方用户推荐。 同样的,CenOS版本非常丰富,适合长期使用。

网上还有其他的资源,我测试了上海交大的就很好。达到8M/S

将/etc/yum.repos.d/CentOS-Base.repo,按照下面的进行修改

# 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-$releasever - Base

baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/os/$basearch/

gpgcheck=1

gpgkey=http://ftp.sjtu.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#released updates 

[updates]

name=CentOS-$releasever - Updates

baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/updates/$basearch/

gpgcheck=1

gpgkey=http://ftp.sjtu.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/extras/$basearch/

gpgcheck=1

gpgkey=http://ftp.sjtu.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://ftp.sjtu.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users

[contrib]

name=CentOS-$releasever - Contrib

baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/contrib/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://ftp.sjtu.edu.cn/centos/RPM-GPG-KEY-CentOS-6

注意baseurl前面的#去掉,否则会提示baseurl未设置

假如替换其他的源,将新的网址替换http://ftp.sjtu.edu.cn/centos即可。

保存后,执行以下命令:

yum clean all

yum clean metadata

yum clean dbcache

yum makecache

yum update

注意:使用root进行以上操作。看看是不是yum update 很快很爽,非常快,而且这个IP还不是直连能上网的IP,是校园网内的IP。 对学生或者老师免费,呵呵学校的资源就是好啊!上Internet,一般网速10M/S,一年200!羡慕现在的211学校的学生!想当年使用兹娃兹娃的拨号上网,真是不堪回首!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: