为了提高安装rpm包的速度,将yum源配置为国内的阿里repo,具体操作如下。
1、查看现有源
[root@localhost ~]# cat /etc/yum.repos.d/CentOS-Base.repo
默认centos官方源
2、备份系统原有的repo
[root@localhost ~]# ll /etc/yum.repos.d/
总用量 32
-rw-r--r--. 1 root root 1664 9月 5 21:05 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 9月 5 21:05 CentOS-CR.repo
-rw-r--r--. 1 root root 649 9月 5 21:05 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 9月 5 21:05 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 9月 5 21:05 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 9月 5 21:05 CentOS-Sources.repo
-rw-r--r--. 1 root root 6639 9月 5 21:05 CentOS-Vault.repo
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir bak20191022
[root@localhost yum.repos.d]# mv * bak20191022/
3、获取阿里centos7的base-repo
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2019-10-22 15:49:07-- http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 124.239.239.226, 124.239.239.227, 124.239.239.228, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|124.239.239.226|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
100%[=====================================================>] 2,523 --.-K/s 用时 0s
2019-10-22 15:49:07 (114 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])
[root@localhost yum.repos.d]# ll
总用量 8
drwxr-xr-x. 2 root root 4096 10月 22 15:46 bak20191022
-rw-r--r--. 1 root root 2523 6月 16 2018 CentOS-Base.repo
4、清除并重新生成yum cache
[root@localhost yum.repos.d]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/10): base/7/x86_64/group_gz | 165 kB 00:00:00
(2/10): base/7/x86_64/primary_db | 6.0 MB 00:00:00
(3/10): base/7/x86_64/filelists_db | 7.3 MB 00:00:00
(4/10): base/7/x86_64/other_db | 2.6 MB 00:00:00
(5/10): extras/7/x86_64/filelists_db | 207 kB 00:00:00
(6/10): extras/7/x86_64/other_db | 100 kB 00:00:00
(7/10): extras/7/x86_64/primary_db | 152 kB 00:00:00
(8/10): updates/7/x86_64/filelists_db | 1.8 MB 00:00:00
(9/10): updates/7/x86_64/primary_db | 2.8 MB 00:00:00
(10/10): updates/7/x86_64/other_db | 215 kB 00:00:00
元数据缓存已建立
5、获取阿里centos7的epel-repo
[root@localhost yum.repos.d]# wget https://mirrors.aliyun.com/repo/epel-7.repo
--2019-10-22 15:51:54-- https://mirrors.aliyun.com/repo/epel-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 101.246.176.210, 101.246.176.211, 101.246.176.212, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|101.246.176.210|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:664 [application/octet-stream]
正在保存至: “epel-7.repo”
100%[=====================================================>] 664 --.-K/s 用时 0s
2019-10-22 15:51:55 (36.9 MB/s) - 已保存 “epel-7.repo” [664/664])
6、清除并创建cache
[root@localhost yum.repos.d]# ll
总用量 12
drwxr-xr-x. 2 root root 4096 10月 22 15:46 bak20191022
-rw-r--r--. 1 root root 2523 6月 16 2018 CentOS-Base.repo
-rw-r--r--. 1 root root 664 5月 11 2018 epel-7.rep
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum makecache