欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【阿里云镜像】更改阿里巴巴开源镜像站镜像之——CentOS镜像

程序员文章站 2022-03-24 09:37:43
...

前言

阿里巴巴 OPSX 开源镜像站,提供 CentOS、Debian、Ubuntu、 Fedora、Arch Linux、Gentoo、openSUSE、Scientific Linux 等主流发行版的软件源镜像。为阿里云和互联网用户提供免费高速的一站式镜像服务

一、什么是阿里巴巴开源镜像站

镜像站官网:阿里巴巴镜像站链接

【阿里云镜像】更改阿里巴巴开源镜像站镜像之——CentOS镜像

二、更换阿里巴巴镜像源操作步骤

参考链接:CentOS镜像

CentOS,是基于 Red Hat Linux 提供的可*使用源代码的企业级 Linux 发行版本;是一个稳定,可预测,可管理和可复制的免费企业级计算平台。

镜像下载地址:
https://mirrors.aliyun.com/centos/
https://mirrors.aliyun.com/centos-vault/

1、备份自带的YUM源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

【阿里云镜像】更改阿里巴巴开源镜像站镜像之——CentOS镜像

2、下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

CentOS 7版本:

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

  1. [root@centos yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  2. --2021-11-22 11:07:13-- https://mirrors.aliyun.com/repo/Centos-7.repo
  3. Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 61.162.46.214, 61.162.46.210, 61.162.46.208, ...
  4. Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|61.162.46.214|:443... connected.
  5. HTTP request sent, awaiting response... 200 OK
  6. Length: 2523 (2.5K) [application/octet-stream]
  7. Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo
  8. 100%[==============================================================================>] 2,523 --.-K/s in 0s
  9. 2021-11-22 11:07:13 (122 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo saved [2523/2523]
  10. [root@centos yum.repos.d]# ll
  11. total 40
  12. drwxr-xr-x 2 root root 6 Nov 22 11:04 backup
  13. -rw-r--r-- 1 root root 2523 Dec 26 2020 CentOS-Base.repo
  14. -rw-r--r--. 1 root root 1664 Nov 23 2018 CentOS-Base.repo.backup
  15. -rw-r--r--. 1 root root 1309 Nov 23 2018 CentOS-CR.repo
  16. -rw-r--r--. 1 root root 649 Nov 23 2018 CentOS-Debuginfo.repo
  17. -rw-r--r--. 1 root root 314 Nov 23 2018 CentOS-fasttrack.repo
  18. -rw-r--r--. 1 root root 630 Nov 23 2018 CentOS-Media.repo
  19. -rw-r--r-- 1 root root 69 Nov 20 07:55 centos.repo.backup
  20. -rw-r--r--. 1 root root 1331 Nov 23 2018 CentOS-Sources.repo
  21. -rw-r--r--. 1 root root 5701 Nov 23 2018 CentOS-Vault.repo
  22. [root@centos yum.repos.d]#

【阿里云镜像】更改阿里巴巴开源镜像站镜像之——CentOS镜像

3、运行 yum makecache 生成缓存

yum makecache

  1. [root@centos yum.repos.d]# yum makecache
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. * base: mirrors.aliyun.com
  5. * extras: mirrors.aliyun.com
  6. * updates: mirrors.aliyun.com
  7. base | 3.6 kB 00:00:00
  8. extras | 2.9 kB 00:00:00
  9. updates | 2.9 kB 00:00:00
  10. (1/6): extras/7/x86_64/filelists_db | 259 kB 00:00:01
  11. (2/6): extras/7/x86_64/other_db | 145 kB 00:00:02
  12. (3/6): base/7/x86_64/other_db | 2.6 MB 00:00:02
  13. (4/6): updates/7/x86_64/other_db | 829 kB 00:00:01
  14. (5/6): base/7/x86_64/filelists_db | 7.2 MB 00:00:06
  15. (6/6): updates/7/x86_64/filelists_db | 6.6 MB 00:00:08
  16. Metadata Cache Created
  17. [root@centos yum.repos.d]#

【阿里云镜像】更改阿里巴巴开源镜像站镜像之——CentOS镜像

4、查看更换的阿里云镜像的仓库是否生效。

yum clean all
yum repolist

  1. [root@centos yum.repos.d]# yum clean all
  2. Loaded plugins: fastestmirror
  3. Cleaning repos: base extras updates
  4. Cleaning up list of fastest mirrors
  5. Other repos take up 41 M of disk space (use --verbose for details)
  6. [root@centos yum.repos.d]# yum repolist
  7. Loaded plugins: fastestmirror
  8. Determining fastest mirrors
  9. * base: mirrors.aliyun.com
  10. * extras: mirrors.aliyun.com
  11. * updates: mirrors.aliyun.com
  12. base | 3.6 kB 00:00:00
  13. extras | 2.9 kB 00:00:00
  14. updates | 2.9 kB 00:00:00
  15. (1/4): base/7/x86_64/group_gz | 153 kB 00:00:00
  16. (2/4): extras/7/x86_64/primary_db | 243 kB 00:00:00
  17. (3/4): updates/7/x86_64/primary_db | 12 MB 00:00:02
  18. (4/4): base/7/x86_64/primary_db | 6.1 MB 00:00:03
  19. repo id repo name status
  20. base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
  21. extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 500
  22. updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 2,963
  23. repolist: 13,535
  24. [root@centos yum.repos.d]#

更换阿里云镜像站——CentOS镜像生效。
【阿里云镜像】更改阿里巴巴开源镜像站镜像之——CentOS镜像