【阿里云镜像】更改阿里巴巴开源镜像站镜像之——CentOS镜像
程序员文章站
2022-03-24 09:37:43
...
前言
阿里巴巴 OPSX 开源镜像站,提供 CentOS、Debian、Ubuntu、 Fedora、Arch Linux、Gentoo、openSUSE、Scientific Linux 等主流发行版的软件源镜像。为阿里云和互联网用户提供免费高速的一站式镜像服务
一、什么是阿里巴巴开源镜像站
镜像站官网:阿里巴巴镜像站链接
二、更换阿里巴巴镜像源操作步骤
参考链接: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
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
[root@centos yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2021-11-22 11:07:13-- https://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 61.162.46.214, 61.162.46.210, 61.162.46.208, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|61.162.46.214|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’
100%[==============================================================================>] 2,523 --.-K/s in 0s
2021-11-22 11:07:13 (122 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]
[root@centos yum.repos.d]# ll
total 40
drwxr-xr-x 2 root root 6 Nov 22 11:04 backup
-rw-r--r-- 1 root root 2523 Dec 26 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1664 Nov 23 2018 CentOS-Base.repo.backup
-rw-r--r--. 1 root root 1309 Nov 23 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Nov 23 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 Nov 23 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Nov 23 2018 CentOS-Media.repo
-rw-r--r-- 1 root root 69 Nov 20 07:55 centos.repo.backup
-rw-r--r--. 1 root root 1331 Nov 23 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23 2018 CentOS-Vault.repo
[root@centos yum.repos.d]#
3、运行 yum makecache 生成缓存
yum makecache
[root@centos yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* 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/6): extras/7/x86_64/filelists_db | 259 kB 00:00:01
(2/6): extras/7/x86_64/other_db | 145 kB 00:00:02
(3/6): base/7/x86_64/other_db | 2.6 MB 00:00:02
(4/6): updates/7/x86_64/other_db | 829 kB 00:00:01
(5/6): base/7/x86_64/filelists_db | 7.2 MB 00:00:06
(6/6): updates/7/x86_64/filelists_db | 6.6 MB 00:00:08
Metadata Cache Created
[root@centos yum.repos.d]#
4、查看更换的阿里云镜像的仓库是否生效。
yum clean all
yum repolist
[root@centos yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up list of fastest mirrors
Other repos take up 41 M of disk space (use --verbose for details)
[root@centos yum.repos.d]# yum repolist
Loaded plugins: 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/4): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/4): extras/7/x86_64/primary_db | 243 kB 00:00:00
(3/4): updates/7/x86_64/primary_db | 12 MB 00:00:02
(4/4): base/7/x86_64/primary_db | 6.1 MB 00:00:03
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 500
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 2,963
repolist: 13,535
[root@centos yum.repos.d]#
更换阿里云镜像站——CentOS镜像生效。