您的位置:首页 > 其它

CentoOS更换yum源

2016-12-11 21:40 281 查看
由于国内Great FireWall 的原因以及RedHat版本的Yum是收费的等原因,需要将包管理工具Yum的源换成别的镜像

本文用的是阿里云的源

切换到yum目录
[root@cloud ~]# cd /etc/yum.repos.d
备份redhat的yum配置文件
[root@cloud yum.repos.d]# cp rhel-source.repo rhel-source.repo.bak
下载阿里云的配置文件
[root@cloud yum.repos.d]# wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
改名
[root@cloud yum.repos.d]# mv CentOS-Base.repo rhel-source.repo
//使用Vim修改配置文件
[root@cloud yum.repos.d]# vim rhel-source.repo
配置文件打开后有两点需要修改

把gpgcheck=1改成gpgcheck=0(关闭某种检查)

修改$releasever相对路径为绝对路径(即为版本号)

下面是我已经修改好的

# 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 - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/os/$basearch/ http://mirrors.aliyuncs.com/centos/6/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/updates/$basearch/ http://mirrors.aliyuncs.com/centos/6/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/extras/$basearch/ http://mirrors.aliyuncs.com/centos/6/extras/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
........//就不全部贴出来了(太长=_=!)
改好后清理yum缓存

[root@cloud yum.repos.d]# yum clean all
清理完后重新建立缓存

[root@cloud yum.repos.d]# yum makecache
更新yum

[root@cloud yum.repos.d]# yum -y update
好的,到此更换yum源完成了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: