解决:Failed to download metadata for repo ‘base‘: Cannot download repomd.xml: Cannot download repodata

1. First check the system information of the machine

[root@h0436 h0436 zlong]# cat /etc/redhat-release

2. Enter yum.repos.d

[root@h0436 zlong]# cd /etc/yum.repos.d

3. View the image file (see which file you need to modify)

[root@h0436 yum.repos.d]# ls
CentOS-Base.repo CentOS-Base.repo.bak epel.repo
CentOS-Base.repo.backup docker-ce.repo


4. Modify the file (mine is the CentOS-Base.repo.backup file)

[root@h0436 yum.repos.d]# vim CentOS-Base.repo.backup 
 

5. If you can't find which folder it is in, you can go in vim for each folder and find CentOS-Base.repo.

6. Just copy the configuration below, press "i" on the keyboard to edit, and press ESC to exit. If you want to save and exit, press: wq, if you don’t want to save and exit, press: q (the places marked in red in the figure are the places after modification)

[base]
name=CentOS- 8 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/ 8 /os/$basearch/
        http://mirrors.aliyuncs.com/ centos/ 8 /os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/ 8 /os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG -KEY-CentOS- 8

#released updates 
[updates]
name=CentOS-8 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/8/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/8/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/8/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-8

#additional packages that may be useful
[extras]
name=CentOS-8 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/8/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/8/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/8/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-8

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-8 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/8/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/8/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/8/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-8

#contrib - packages by Centos Users
[contrib]
name=CentOS-8 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/8/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/8/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/8/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-8

7. Clear cache

[root@h0436 yum.repos.d]# yum clean all


8. Load cache

[root@h0436 yum.repos.d]# yum makecache

Hope to help you, thank you~

Guess you like

Origin blog.csdn.net/Along_168163/article/details/124338818