如下所示,这是在CentOS 6中发生的问题:
[root@fastvm-centos-6-10-51 ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/extras/mirrorlist.txt
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/updates/mirrorlist.txt
repo id repo name status
base CentOS-6 - Base 0
extras CentOS-6 - Extras 0
updates CentOS-6 - Updates 0
repolist: 0
原因是由于2020-11-30,CentOS 6的EOL已从fastmirror站点中删除。
如下所示,将CentOS Vault存储库添加到mirrorlist.txt。
$ echo "https://vault.centos.org/6.10/os/x86_64/" > /var/cache/yum/x86_64/6/base/mirrorlist.txt
$ echo "https://vault.centos.org/6.10/extras/x86_64/" > /var/cache/yum/x86_64/6/extras/mirrorlist.txt
$ echo "https://vault.centos.org/6.10/updates/x86_64/" > /var/cache/yum/x86_64/6/updates/mirrorlist.txt
添加后,您可以看到yum repolist的工作原理如下:
[root@fastvm-centos-6-10-51 ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 3.7 kB 00:00
base/primary_db | 4.7 MB 00:03
extras | 3.4 kB 00:00
extras/primary_db | 29 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 12 MB 00:07
repo id repo name status
base CentOS-6 - Base 6,713
extras CentOS-6 - Extras 47
updates CentOS-6 - Updates 1,193
repolist: 7,953
如果按上述方法应用,则在执行yum clean all命令时将再次发生相同的问题,
如下所示,在/etc/yum.repos.d/下修改回购文件,
$ sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\/mirrorlist.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo
$ sed -i -e "s/^#baseurl=http:\/\/mirror.centos.org/baseurl=https:\/\/vault.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo
仓库如下所示进行修改:
$ diff CentOS-Base.repo.old CentOS-Base.repo
15,16c15,16 < mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
< #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ --- > #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
> baseurl=https://vault.centos.org/centos/$releasever/os/$basearch/ 23,24c23,24 < mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
< #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ --- > #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
> baseurl=https://vault.centos.org/centos/$releasever/updates/$basearch/ 31,32c31,32 < mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
< #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ --- > #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
> baseurl=https://vault.centos.org/centos/$releasever/extras/$basearch/
如下所示,即使yum缓存是干净的,也会维护镜像站点信息:
[root@fastvm-centos-6-10-51 yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up Everything
[root@fastvm-centos-6-10-51 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 3.7 kB 00:00
base/primary_db | 4.7 MB 00:03
extras | 3.4 kB 00:00
extras/primary_db | 29 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 12 MB 00:07
repo id repo name status
base CentOS-6 - Base 6,713
extras CentOS-6 - Extras 47
updates CentOS-6 - Updates 1,193
repolist: 7,953
[root@fastvm-centos-6-10-51 yum.repos.d]#
保管库非常慢…