Linux Redhat 和 CentOS配置國內163的yum源

Redhat和CentOS的默認yum源都是國外的,國內環境訪問會比較慢,感謝163鏡像,直接直接在國內訪問。本文最簡方式記錄下配置。html

163鏡像源

首先請訪問:http://mirrors.163.com/.help/ ,直接查看163鏡像源的幫助說明。其中CentOS能夠支持5,6,7多個版本,同時也適應於對應的redhat版本。詳情請參考:http://mirrors.163.com/.help/centos.htmlvim

安裝配置

  1. 首先備份本機默認的CentOS-Base.repo文件(若是你有的話)
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. 首先根據本地版本選擇對應的鏡像配置,並下載.

首先在服務器上查看版本centos

# 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配置文件。其餘版本相似。bash

  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保存退出。url

  1. 清理並從新下載yum配置
yum clean all
yum makecache

OK, 完成,你能夠使用:yum install anything~~code

相關文章
相關標籤/搜索