跳至正文

Centos7 中使用阿里云的yum源

1. 备份原来的yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2. 下载阿里云的CentOS-Base.repo 到/etc/yum.repos.d/

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

执行结果如下:

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2019-05-07 07:52:44--  http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 183.245.11.231, 111.3.79.229, 183.245.11.232, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|183.245.11.231|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

100%[=================================================================================>] 2,523       --.-K/s   in 0s      

2019-05-07 07:52:44 (84.8 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]

3. 清理缓存

sudo yum clean all

执行结果:

[root@localhost ~]# sudo yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates
Cleaning up list of fastest mirrors

4. 生成新的缓存

sudo yum makecache

执行结果:

[root@localhost ~]# sudo yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink                                                                                                           | 8.6 kB  00:00:00     
 * base: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                           | 3.6 kB  00:00:00     
epel                                                                                                                           | 4.7 kB  00:00:00     
extras                                                                                                                         | 3.4 kB  00:00:00     
updates                                                                                                                        | 3.4 kB  00:00:00     
(1/18): base/7/x86_64/group_gz                                                                                                 | 166 kB  00:00:00     
(2/18): base/7/x86_64/primary_db                                                                                               | 6.0 MB  00:00:00     
(3/18): base/7/x86_64/filelists_db                                                                                             | 7.1 MB  00:00:01     
(4/18): epel/x86_64/group_gz                                                                                                   |  88 kB  00:00:00     
(5/18): base/7/x86_64/other_db                                                                                                 | 2.6 MB  00:00:00     
(6/18): epel/x86_64/filelists_db                                                                                               |  11 MB  00:00:01     
(7/18): epel/x86_64/updateinfo                                                                                                 | 992 kB  00:00:00     
(8/18): epel/x86_64/prestodelta                                                                                                |  955 B  00:00:00     
(9/18): epel/x86_64/primary_db                                                                                                 | 6.7 MB  00:00:00     
(10/18): extras/7/x86_64/prestodelta                                                                                           |  62 kB  00:00:00     
(11/18): extras/7/x86_64/filelists_db                                                                                          | 243 kB  00:00:00     
(12/18): extras/7/x86_64/primary_db                                                                                            | 201 kB  00:00:00     
(13/18): extras/7/x86_64/other_db                                                                                              | 126 kB  00:00:00     
(14/18): epel/x86_64/other_db                                                                                                  | 3.2 MB  00:00:00     
(15/18): updates/7/x86_64/prestodelta                                                                                          | 623 kB  00:00:00     
(16/18): updates/7/x86_64/filelists_db                                                                                         | 3.4 MB  00:00:00     
(17/18): updates/7/x86_64/other_db                                                                                             | 563 kB  00:00:00     
(18/18): updates/7/x86_64/primary_db                                                                                           | 4.2 MB  00:00:00     
Metadata Cache Created

相关链接:

阿里云开源镜像站

标签: