CentOS 7 更新源 – 使用国内 163 yum 源

 

1.切到源目录:

[root@localhost ~]# cd /etc/yum.repos.d/

[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo


2.备份源文件

[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup
[root@localhost yum.repos.d]# ls
CentOS-Base.repo.backup  CentOS-fasttrack.repo  CentOS-Vault.repo
CentOS-CR.repo           CentOS-Media.repo
CentOS-Debuginfo.repo    CentOS-Sources.repo


3.下载163源文件

[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
--2016-03-21 11:45:43--  http://mirrors.163.com/.help/CentOS7-Base-163.repo
Resolving mirrors.163.com (mirrors.163.com)... 123.58.173.186, 123.58.173.185
Connecting to mirrors.163.com (mirrors.163.com)|123.58.173.186|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1572 (1.5K) [application/octet-stream]
Saving to: CentOS7-Base-163.repo


100%[======================================>] 1,572       --.-K/s   in 0s      


2016-03-21 11:45:43 (68.7 MB/s) - CentOS7-Base-163.repo saved [1572/1572]


[root@localhost yum.repos.d]# ls -al
total 48
drwxr-xr-x.  2 root root 4096 Mar 21 11:45 .
drwxr-xr-x. 76 root root 8192 Mar 21 10:39 ..
-rw-r--r--.  1 root root 1572 May 18  2015 CentOS7-Base-163.repo
-rw-r--r--.  1 root root 1664 Dec  9 17:59 CentOS-Base.repo.backup
-rw-r--r--.  1 root root 1309 Dec  9 17:59 CentOS-CR.repo
-rw-r--r--.  1 root root  649 Dec  9 17:59 CentOS-Debuginfo.repo
-rw-r--r--.  1 root root  290 Dec  9 17:59 CentOS-fasttrack.repo
-rw-r--r--.  1 root root  630 Dec  9 17:59 CentOS-Media.repo
-rw-r--r--.  1 root root 1331 Dec  9 17:59 CentOS-Sources.repo

-rw-r--r--.  1 root root 1952 Dec  9 17:59 CentOS-Vault.repo


4.生成缓存

[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
base                                                     | 3.6 kB     00:00     
extras                                                   | 3.4 kB     00:00     
updates                                                  | 3.4 kB     00:00     
(1/12): base/7/x86_64/group_gz                             | 155 kB   00:00     
(2/12): base/7/x86_64/filelists_db                         | 6.2 MB   00:14     
(3/12): extras/7/x86_64/prestodelta                        |  25 kB   00:00     
(4/12): extras/7/x86_64/primary_db                         | 101 kB   00:00     
(5/12): extras/7/x86_64/filelists_db                       | 258 kB   00:01     
(6/12): updates/7/x86_64/prestodelta                       | 275 kB   00:01     
(7/12): extras/7/x86_64/other_db                           | 317 kB   00:05     
(8/12): base/7/x86_64/other_db                             | 2.3 MB   00:08     
(9/12): base/7/x86_64/primary_db                           | 5.3 MB   00:21     
(10/12): updates/7/x86_64/filelists_db                     | 1.9 MB   00:07     
(11/12): updates/7/x86_64/primary_db                       | 3.2 MB   00:10     
(12/12): updates/7/x86_64/other_db                         |  27 MB   00:45     
Determining fastest mirrors
Metadata Cache Created
[root@localhost yum.repos.d]#