教你优化yum源。配置阿里云的yum镜像源(base和epel)

一、Centos7的base源配置阿里云的yum源:

1、备份旧的yum源目录下的所有文件

[root@ELK-chaofeng07 yum.repos.d]# mkdir ../yum.repos.d.bak ; mv ./* ../yum.repos.d.bak

2、下载base文件

#各系统版本repo文件对应的下载操作
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3、清空缓存

yum clean all

4、构建新的缓存

yum makecache

5、查看基本yum源

[root@ELK-chaofeng07 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
repo id                                                            repo name                                                                                         status
base/7/x86_64                                                      CentOS-7 - Base - mirrors.aliyun.com                                                              10,019
*epel/x86_64                                                       Extra Packages for Enterprise Linux 7 - x86_64                                                    12,906
extras/7/x86_64                                                    CentOS-7 - Extras - mirrors.aliyun.com                                                               371
updates/7/x86_64                                                   CentOS-7 - Updates - mirrors.aliyun.com                                                            1,158
repolist: 24,454

二、配置阿里云的epel源

1、下载阿里云的epel源。我们到官网:http://mirrors.aliyun.com

教你优化yum源。配置阿里云的yum镜像源(base和epel)_第1张图片

2、开始备份旧的epel-release源

mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup

3、下载新的阿里云的epel源

epel(RHEL 7)

    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
epel(RHEL 6)

    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
epel(RHEL 5)

    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo

4、清空缓存

[root@ELK-chaofeng07 yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors

4、构建新的缓存

[root@ELK-chaofeng07 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
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:01     
(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/updateinfo                                  | 953 kB  00:00:00     
(7/18): epel/x86_64/prestodelta                                 |  11 kB  00:00:00     
(8/18): epel/x86_64/primary_db                                  | 6.6 MB  00:00:01     
(9/18): epel/x86_64/filelists_db                                |  11 MB  00:00:02     
(10/18): extras/7/x86_64/prestodelta                            |  47 kB  00:00:00     
(11/18): extras/7/x86_64/filelists_db                           | 231 kB  00:00:00     
(12/18): epel/x86_64/other_db                                   | 3.2 MB  00:00:00     
(13/18): extras/7/x86_64/primary_db                             | 180 kB  00:00:00     
(14/18): extras/7/x86_64/other_db                               | 118 kB  00:00:00     
(15/18): updates/7/x86_64/prestodelta                           | 357 kB  00:00:00     
(16/18): updates/7/x86_64/filelists_db                          | 2.2 MB  00:00:00     
(17/18): updates/7/x86_64/other_db                              | 349 kB  00:00:00     
(18/18): updates/7/x86_64/primary_db                            | 2.5 MB  00:00:00     
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Metadata Cache Created

5、查看yum源

[root@ELK-chaofeng07 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
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:01     
(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/updateinfo                                  | 953 kB  00:00:00     
(7/18): epel/x86_64/prestodelta                                 |  11 kB  00:00:00     
(8/18): epel/x86_64/primary_db                                  | 6.6 MB  00:00:01     
(9/18): epel/x86_64/filelists_db                                |  11 MB  00:00:02     
(10/18): extras/7/x86_64/prestodelta                            |  47 kB  00:00:00     
(11/18): extras/7/x86_64/filelists_db                           | 231 kB  00:00:00     
(12/18): epel/x86_64/other_db                                   | 3.2 MB  00:00:00     
(13/18): extras/7/x86_64/primary_db                             | 180 kB  00:00:00     
(14/18): extras/7/x86_64/other_db                               | 118 kB  00:00:00     
(15/18): updates/7/x86_64/prestodelta                           | 357 kB  00:00:00     
(16/18): updates/7/x86_64/filelists_db                          | 2.2 MB  00:00:00     
(17/18): updates/7/x86_64/other_db                              | 349 kB  00:00:00     
(18/18): updates/7/x86_64/primary_db                            | 2.5 MB  00:00:00     
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Metadata Cache Created

此时再次下载东西你会发现非常快。不懂请点击

转载于:https://www.cnblogs.com/FengGeBlog/p/10353176.html

你可能感兴趣的:(教你优化yum源。配置阿里云的yum镜像源(base和epel))