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

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

163镜像源

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

安装配置

  1. 首先备份本机默认的CentOS-Base.repo文件(如果你有的话)
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. 首先根据本地版本选择对应的镜像配置,并下载.

首先在服务器上查看版本

# 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配置文件。其他版本类似。

  1. 修改下配置,默认的模式有问题(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保存退出。

  1. 清理并重新下载yum配置
yum clean all
yum makecache

OK, 完成,你可以使用:yum install anything~~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zp820705

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值