[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup centos
方法1:wget直接下載
執行命令:緩存
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
操做以下:app
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2018-02-09 05:54:04-- http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主機 mirrors.aliyun.com (mirrors.aliyun.com)... 180.101.150.31, 180.101.150.28, 180.101.150.26, ...
正在鏈接 mirrors.aliyun.com (mirrors.aliyun.com)|180.101.150.31|:80... 已鏈接。
已發出 HTTP 請求,正在等待迴應... 200 OK
長度:2573 (2.5K) [application/octet-stream]
正在保存至: 「/etc/yum.repos.d/CentOS-Base.repo」curl100%[==============================================================================>] 2,573 --.-K/s 用時 0s url
2018-02-09 05:54:05 (281 MB/s) - 已保存 「/etc/yum.repos.d/CentOS-Base.repo」 [2573/2573])spa
方法2:curl直接下載
執行命令:插件
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
操做以下:rest
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2573 100 2573 0 0 8533 0 --:--:-- --:--:-- --:--:-- 8548
方法3:在CentOS-Base.repo 寫入地址
code
[root@localhost yum.repos.d]# vi CentOS-Base.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[root@localhost yum.repos.d]# yum makecache
已加載插件:fastestmirror, langpacks
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30000 milliseconds')正在嘗試其它鏡像。base | 3.6 kB 00:00:00extras | 3.4 kB 00:00:00updates | 3.4 kB 00:00:00(1/5): extras/7/x86_64/prestodelta | 102 kB 00:00:01(2/5): extras/7/x86_64/other_db | 108 kB 00:00:00(3/5): extras/7/x86_64/filelists_db | 636 kB 00:00:01(4/5): base/7/x86_64/other_db | 2.5 MB 00:00:02(5/5): base/7/x86_64/filelists_db | 6.7 MB 00:00:02Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com元數據緩存已創建