centos设置163 yum更新源

说明:
centos默认的yum更新源为mirrorlist.centos.org,由于身处国外,速度较慢,因此将yum更新源设置为163.
国内提供yum更新源的,有很多,如清华,中科大,搜狐等。这里,我选择的是163

实现:
1.获取CentOS_Base.repo配置文件

# cd /etc/yum.repos.d/
# mv CentOS-Base.repo CentOS-Base.repo.bak   //备份原始配置文件
# wget http://dl.gaingreat.com/CentOS6-Base-163.repo  //获取CentOS 6.*的repo,注意将CentOS6-Base-163.repo所有的$releasever改为6!!!也可以复制附录2内容到CentOS_Base.repo。CentOS 5.*为http://dl.gaingreat.com/CentOS5-Base-163.repo

 
2.删除缓存,重新更新

# yum clean all
# yum makecache  //也可以yum-plugin-fastestmirror(自动添加高速源,自动挑选快的镜像站,未试)
# yum install yum-fastestmirror
注:确定/etc/yum.conf中的plugins=1

 
附录:
附录1:yum update出现关于addons相关问题。因为centos 6.*已经将[addons]已经替换为[centosplus],所以需要将[addons]那段注释或删掉。centos 5.*不需要更改。具体可以到http://mirrors.163.com/centos查看下面有哪些目录。

附录2:# cat CentOS-Base.repo //CentOS 6.*内容,注意将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-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&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-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&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-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&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-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 
附录3:CentOS [Errno 14] PYCURL ERROR 6 – ""
使用CentOS 6的过程中遇到的些问题,有些其实与版本无关,是系统管理方面的问题,比如yum update 时,出现了大量的 [Errno 14] PYCURL ERROR 6 – “” 错误。
有可能是因为系统nameserver没有配置好或者说DNS解析有问题,网络有问题也是有可能的
修改/etc/resolv.conf,原来的配置为

# Generated by NetworkManager
search 202.96.209.6
nameserver 202.96.209.6

可能202.96.209.6这个DNS服务器已经不能正常工作,修改后的配置

# Generated by NetworkManager
#search 202.96.209.133
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 202.96.209.6

发表评论

邮箱地址不会被公开。 必填项已用*标注