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

Linux Redhat 和 CentOS配置国内163的yum源

2016-11-07 00:00 387 查看
Redhat和CentOS的默认yum源都是国外的,国内环境访问会比较慢,感谢163镜像,直接直接在国内访问。本文最简方式记录下配置。

163镜像源

首先请访问:http://mirrors.163.com/.help/ ,直接查看163镜像源的帮助说明。其中CentOS可以支持5,6,7多个版本,同时也适应于对应的redhat版本。详情请参考:http://mirrors.163.com/.help/centos.html

安装配置

首先备份本机默认的CentOS-Base.repo文件(如果你有的话)

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


首先根据本地版本选择对应的镜像配置,并下载.

首先在服务器上查看版本

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.2 (Santiago)
# cd /etc/yum.repos.d/
# wget  http://mirrors.163.com/.help/CentOS6-Base-163.repo

如果返回是6.x则便是是6这个版本,请选择下载6对应的yum配置文件。其他版本类似。

CentOS 5 : wget http://mirrors.163.com/.help/CentOS5-Base-163.repo

CentOS 6 : wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

CentOS 7 : wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

修改下配置,默认的模式有问题(redhat6.2下测试)~

使用vim打开新下载的CentOS6-Base-163.repo,手动修改下配置文件里面所有baseurl属性值的$releasever为对应的OS主版本号(5,6,7),如:

[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

修改为:

[base]
name=CentOS-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

完成后,:wq保存退出。

清理并重新下载yum配置

yum clean all
yum makecache

OK, 完成,你可以使用:yum install anything~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux yum