备份系统自带源
将系统自带的CentOS-Base.repo文件备份到CentOS-Base.repo.backup文件
[root@eth131 ~]# cd /etc/yum.repos.d
[root@eth131 yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup
[root@eth131 yum.repos.d]# ll
总用量 44
-rw-r--r--. 1 root root 1664 9月 5 21:05 CentOS-Base.repo.backup
-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
-rw-r--r--. 1 root root 2640 12月 14 15:57 docker-ce.repo
-rw-r--r--. 1 root root 951 10月 3 2017 epel.repo
-rw-r--r--. 1 root root 1050 10月 3 2017 epel-testing.repo
下载阿里yum源
从官网下载:保存为CentOS-Base.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@eth131 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2020-02-14 20:58:48-- http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 58.215.158.242, 58.215.158.243, 58.215.158.239, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|58.215.158.242|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
100%[========================================>] 2,523 --.-K/s 用时 0.002s
2020-02-14 20:58:48 (1.43 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])
刷新缓存
先清空缓存:yum clean all 再重新更新缓存:yum makecache
[root@eth131 yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base docker-ce-stable epel extras updates
Cleaning up list of fastest mirrors
Other repos take up 1.5 M of disk space (use --verbose for details)
[root@eth131 yum.repos.d]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
epel/x86_64/metalink | 9.1 kB 00:00:00
* base: mirrors.aliyun.com
* epel: ftp.iij.ad.jp
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 5.3 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/20): base/7/x86_64/group_gz | 165 kB 00:00:01
......
(19/20): epel/x86_64/filelists_db | 12 MB 00:00:05
(20/20): epel/x86_64/other_db | 3.3 MB 00:05:54
元数据缓存已建立