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
相关推荐
未来会更好yes4 分钟前
Alibaba Cloud Linux3.21.04 ModSecurity 3 + Nginx + OWASP CRS 完整安装流程
linux·waf·modsecurity
XH-hui5 分钟前
【打靶日记】HackMyVm 之 Twisted
linux·网络安全·hackmyvm·hmv
Evan芙15 分钟前
Rocky Linux 9 双网卡 bond0 绑定
linux·服务器·网络
保持低旋律节奏22 分钟前
linux——vim编辑器
linux·编辑器·vim
python百炼成钢38 分钟前
49.Linux音频驱动
android·linux·音视频
TangGeeA39 分钟前
Linux CFS(完全公平调度器)全面总结
java·linux·服务器
MZZDX1 小时前
Linux操作系统相关知识总结
linux
Ronin3051 小时前
【Linux网络】网络层IP协议
linux·网络·tcp/ip·网络层·ip协议
爱吃山竹的大肚肚1 小时前
根据每个键对应的列表里所有实体的 count 最大值,将整个字典从大到小重新排列
linux·运维·windows
赖small强1 小时前
【Linux驱动开发】Linux虚拟文件系统(VFS)技术架构深度解析
linux·驱动开发·vfs·inode·ext4·superblock·目录项