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

修改CentOS預設yum源為國內yum映象源

有時候CentOS預設的yum源不一定是國內映象,導致yum線上安裝及更新速度不是很理想。這時候需要將yum源設定為國內映象站點。國內主要開源的開源映象站點應該是網易和阿里雲了。

1. 首先備份系統自帶yum源配置檔案/etc/yum.repos.d/CentOS-Base.repo
[[email protected] ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. 進入yum源配置檔案所在的資料夾
[[email protected] ~]# cd /etc/yum.repos.d/
3. 下載163的yum源配置檔案到上面那個資料夾內
  • 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 makecache生成快取
[[email protected] yum.repos.d]# yum makecache
5. 這時候再更新系統就會看到以下mirrors.163.com資訊
[[email protected] yum.repos.d]# yum -y update
已載入外掛:fastestmirror, refresh-packagekit, security
設定更新程序Loading mirror speeds from cached hostfile
 - base: mirrors.163.com
 - extras: mirrors.163.com
 - updates: mirrors.163.com
1. 首先備份系統自帶yum源配置檔案/etc/yum.repos.d/CentOS-Base.repo
[[email protected] ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. 下載ailiyun的yum源配置檔案到/etc/yum.repos.d/
  • CentOS7
[[email protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  • CentOS6
[[email protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
  • CentOS5
[[email protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
3. 執行yum makecache生成快取
[[email protected] ~]# yum makecache
4. 這時候再更新系統就會看到以下mirrors.aliyun.com資訊
[[email protected] ~]# yum -y update
已載入外掛:fastestmirror, refresh-packagekit, security
設定更新程序Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com