CentOS 7 更新baseurl_for_repo

简介

在centos7 中运行 yum 相关操作遇到报错

1
[CentOS 7 Cannot find a valid baseurl for repo: base/7/x86_64 when I run yum update]

其实就是 centos7 太老了。

解决方法

1
2
3
4
5
6
7
8
9
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

sudo vim /etc/yum.repos.d/CentOS-Base.repo

# And comment out all the mirrorlist lines.
# And uncomment all the baseurl lines.
# For CentOS version 8 and below you will also need to change `mirror.centos` to `vault.centos` in the baseurl lines as they are deprecated.

# 就是注释掉mirro 列,打开 baseurl列,然后把mirror.centos都改成 vault.centos。

参考:

https://superuser.com/questions/1373881/centos-7-cannot-find-a-valid-baseurl-for-repo-base-7-x86-64-when-i-run-yum-upda