如下所示,这是在CentOS 6中发生的问题:

    1. [root@fastvm-centos-6-10-51 ~]# yum repolist
    2. Loaded plugins: fastestmirror
    3. Determining fastest mirrors
    4. YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
    5. Eg. Invalid release/repo/arch combination/
    6. removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
    7. YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
    8. Eg. Invalid release/repo/arch combination/
    9. removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/extras/mirrorlist.txt
    10. YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
    11. Eg. Invalid release/repo/arch combination/
    12. removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/updates/mirrorlist.txt
    13. repo id repo name status
    14. base CentOS-6 - Base 0
    15. extras CentOS-6 - Extras 0
    16. updates CentOS-6 - Updates 0
    17. repolist: 0

    原因是由于2020-11-30,CentOS 6的EOL已从fastmirror站点中删除。
    如下所示,将CentOS Vault存储库添加到mirrorlist.txt。

    1. $ echo "https://vault.centos.org/6.10/os/x86_64/" > /var/cache/yum/x86_64/6/base/mirrorlist.txt
    2. $ echo "https://vault.centos.org/6.10/extras/x86_64/" > /var/cache/yum/x86_64/6/extras/mirrorlist.txt
    3. $ echo "https://vault.centos.org/6.10/updates/x86_64/" > /var/cache/yum/x86_64/6/updates/mirrorlist.txt

    添加后,您可以看到yum repolist的工作原理如下:

    1. [root@fastvm-centos-6-10-51 ~]# yum repolist
    2. Loaded plugins: fastestmirror
    3. Determining fastest mirrors
    4. base | 3.7 kB 00:00
    5. base/primary_db | 4.7 MB 00:03
    6. extras | 3.4 kB 00:00
    7. extras/primary_db | 29 kB 00:00
    8. updates | 3.4 kB 00:00
    9. updates/primary_db | 12 MB 00:07
    10. repo id repo name status
    11. base CentOS-6 - Base 6,713
    12. extras CentOS-6 - Extras 47
    13. updates CentOS-6 - Updates 1,193
    14. repolist: 7,953

    如果按上述方法应用,则在执行yum clean all命令时将再次发生相同的问题,
    如下所示,在/etc/yum.repos.d/下修改回购文件,

    1. $ sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\/mirrorlist.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo
    2. $ sed -i -e "s/^#baseurl=http:\/\/mirror.centos.org/baseurl=https:\/\/vault.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo

    仓库如下所示进行修改:

    1. $ diff CentOS-Base.repo.old CentOS-Base.repo
    2. 15,16c15,16 < mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
    3. < #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ --- > #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
    4. > 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
    5. < #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ --- > #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
    6. > 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
    7. < #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ --- > #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
    8. > baseurl=https://vault.centos.org/centos/$releasever/extras/$basearch/

    如下所示,即使yum缓存是干净的,也会维护镜像站点信息:

    1. [root@fastvm-centos-6-10-51 yum.repos.d]# yum clean all
    2. Loaded plugins: fastestmirror
    3. Cleaning repos: base extras updates
    4. Cleaning up Everything
    5. [root@fastvm-centos-6-10-51 yum.repos.d]# yum repolist
    6. Loaded plugins: fastestmirror
    7. Determining fastest mirrors
    8. base | 3.7 kB 00:00
    9. base/primary_db | 4.7 MB 00:03
    10. extras | 3.4 kB 00:00
    11. extras/primary_db | 29 kB 00:00
    12. updates | 3.4 kB 00:00
    13. updates/primary_db | 12 MB 00:07
    14. repo id repo name status
    15. base CentOS-6 - Base 6,713
    16. extras CentOS-6 - Extras 47
    17. updates CentOS-6 - Updates 1,193
    18. repolist: 7,953
    19. [root@fastvm-centos-6-10-51 yum.repos.d]#

    保管库非常慢…