**原因:**CentOS 7 的官方仓库在 2024 年 6 月 30 日之后已经停止维护,不需要再去检查什么网络、DNS等乱七八糟的,因为这玩意都停止维护了,就算其他配置正常也照样不通。
**解决:**将CentOS-Base.repo文件替换成下面的配置
javascript
[root@VM-20-15-centos]# cd /etc/yum.repos.d
[root@VM-20-15-centos yum.repos.d]# cat CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras
baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@VM-20-15-centos yum.repos.d]# yum clean all
[root@VM-20-15-centos yum.repos.d]# yum update
这里由于之前由腾讯云yum源换aliyun的yum源时执行yum update出现了这个报错,所以用了以上方法解决了yum update问题,然后感觉还是喜欢阿里云,所以就换上阿里云了,再执行yum update就没报错了,换阿里云的操作步骤如下:
javascript
// 习惯性备份
mv CentOS-Base.repo CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum update