1. 程式人生 > >更改CentOS預設yum映象源為國內的yum映象源

更改CentOS預設yum映象源為國內的yum映象源

剛安裝完的CentOS系統,預設帶的yum映象源一般都是國外的,導致線上安裝的時候,速度很慢。這個時候需要你更換yum映象源為國內的,國內主要開源的開源映象點應該算是阿里和網易了。 

網易:http://mirrors.163.com.centos/   

阿里雲:http://mirros.aliyun.com/centos

修改CentOS預設yum源為mirrors.163.com

1、備份系統自帶的yum映象源 /etc/yum.repos.d/CentOS-Base.repo 

[[email protected] yum.repos.d]#mv /etc/yum.repos.d/CentOS-Base.repo  /etc/yum.repos.d/CentOS-Base.repo.backup

2、檢視自己按照的centOS系統的版本

[[email protected] ~]# cat /etc/system-release
CentOS release 6.7 (Final)


3、根據系統版本號,下載對應yum源配置檔案到上面那個資料夾內

進入到yum源配置檔案所在的資料夾

[[email protected] ~]# cd /etc/yum.repos.d/

CentOS7

[[email protected] yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

CentOS6
[[email protected]
yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

CentOS5
[[email protected] yum.repos.d]# wget http://mirrors.163.com/.help/CentOS5-Base-163.repo

4、執行yum生成快取
[[email protected] yum.repos.d]# yum makecache

5、更新系統就能看到mirrors.163.com資訊
[[email protected] yum.repos.d]# yum -y update
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Update Process
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
用阿里雲,只要下載aliyun的yum配置檔案到/etc/yum.repos.d/,其它步驟一致

CentOS7

[[email protected] yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
CentOS6
[[email protected] yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS5

[[email protected] yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo