centos7执行yum操作时报错Could not retrieve mirrorlist http://mirrorlist.centos.org解决

**原因:**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
相关推荐
牧以南歌〆3 小时前
在Ubuntu主机中修改ARM Linux开发板的根文件系统
linux·arm开发·驱动开发·ubuntu
夜月yeyue4 小时前
设计模式分析
linux·c++·stm32·单片机·嵌入式硬件
kfepiza4 小时前
Debian的`/etc/network/interfaces`的`allow-hotplug`和`auto`对比讲解 笔记250704
linux·服务器·网络·笔记·debian
cuijiecheng20185 小时前
Ubuntu下布署mediasoup-demo
linux·运维·ubuntu
独行soc7 小时前
2025年渗透测试面试题总结-2025年HW(护网面试) 33(题目+回答)
linux·科技·安全·网络安全·面试·职场和发展·护网
java龙王*7 小时前
开放端口,开通数据库连接权限,无法连接远程数据库 解决方案
linux
蓝易云7 小时前
CentOS 7上安装X virtual framebuffer (Xvfb) 的步骤以及如何解决无X服务器的问题
前端·后端·centos
bcbobo21cn8 小时前
Linux命令的命令历史
linux·histsize·histfile
jingyu飞鸟9 小时前
linux系统源代码安装apache、编译隐藏版本号
linux·运维·apache
世事如云有卷舒9 小时前
Ubunt20.04搭建GitLab服务器,并借助cpolar实现公网访问
linux·服务器·gitlab