备份系统自带源

将系统自带的CentOS-Base.repo文件备份到CentOS-Base.repo.backup文件

  1. [root@eth131 ~]# cd /etc/yum.repos.d
  2. [root@eth131 yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup
  3. [root@eth131 yum.repos.d]# ll
  4. 总用量 44
  5. -rw-r--r--. 1 root root 1664 9 5 21:05 CentOS-Base.repo.backup
  6. -rw-r--r--. 1 root root 1309 9 5 21:05 CentOS-CR.repo
  7. -rw-r--r--. 1 root root 649 9 5 21:05 CentOS-Debuginfo.repo
  8. -rw-r--r--. 1 root root 314 9 5 21:05 CentOS-fasttrack.repo
  9. -rw-r--r--. 1 root root 630 9 5 21:05 CentOS-Media.repo
  10. -rw-r--r--. 1 root root 1331 9 5 21:05 CentOS-Sources.repo
  11. -rw-r--r--. 1 root root 6639 9 5 21:05 CentOS-Vault.repo
  12. -rw-r--r--. 1 root root 2640 12 14 15:57 docker-ce.repo
  13. -rw-r--r--. 1 root root 951 10 3 2017 epel.repo
  14. -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

  1. [root@eth131 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  2. --2020-02-14 20:58:48-- http://mirrors.aliyun.com/repo/Centos-7.repo
  3. 正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 58.215.158.242, 58.215.158.243, 58.215.158.239, ...
  4. 正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|58.215.158.242|:80... 已连接。
  5. 已发出 HTTP 请求,正在等待回应... 200 OK
  6. 长度:2523 (2.5K) [application/octet-stream]
  7. 正在保存至: “/etc/yum.repos.d/CentOS-Base.repo
  8. 100%[========================================>] 2,523 --.-K/s 用时 0.002s
  9. 2020-02-14 20:58:48 (1.43 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo [2523/2523])

刷新缓存

先清空缓存:yum clean all 再重新更新缓存:yum makecache

  1. [root@eth131 yum.repos.d]# yum clean all
  2. 已加载插件:fastestmirror
  3. 正在清理软件源: base docker-ce-stable epel extras updates
  4. Cleaning up list of fastest mirrors
  5. Other repos take up 1.5 M of disk space (use --verbose for details)
  6. [root@eth131 yum.repos.d]# yum makecache
  7. 已加载插件:fastestmirror
  8. Determining fastest mirrors
  9. epel/x86_64/metalink | 9.1 kB 00:00:00
  10. * base: mirrors.aliyun.com
  11. * epel: ftp.iij.ad.jp
  12. * extras: mirrors.aliyun.com
  13. * updates: mirrors.aliyun.com
  14. base | 3.6 kB 00:00:00
  15. docker-ce-stable | 3.5 kB 00:00:00
  16. epel | 5.3 kB 00:00:00
  17. extras | 2.9 kB 00:00:00
  18. updates | 2.9 kB 00:00:00
  19. (1/20): base/7/x86_64/group_gz | 165 kB 00:00:01
  20. ......
  21. (19/20): epel/x86_64/filelists_db | 12 MB 00:00:05
  22. (20/20): epel/x86_64/other_db | 3.3 MB 00:05:54
  23. 元数据缓存已建立