教你優化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

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

此時再次下載東西你會發現非常快。不懂請點擊


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM