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
相关推荐
apocelipes2 小时前
Linux c 运行时获取动态库所在路径
linux·c语言·linux编程
努力学习的小廉2 小时前
深入了解linux系统—— 进程池
linux·运维·服务器
秃头菜狗3 小时前
各个主要目录的功能 / Linux 常见指令
linux·运维·服务器
2301_793102493 小时前
Linux——MySql数据库
linux·数据库
jiunian_cn4 小时前
【Linux】centos软件安装
linux·运维·centos
睡觉待开机4 小时前
0. MySQL在Centos 7环境安装
数据库·mysql·centos
程序员JerrySUN4 小时前
[特殊字符] 深入理解 Linux 内核进程管理:架构、核心函数与调度机制
java·linux·架构
孤寂大仙v4 小时前
【计算机网络】非阻塞IO——select实现多路转接
linux·计算机网络
派阿喵搞电子5 小时前
Ubuntu下有关UDP网络通信的指令
linux·服务器·网络
Evan_ZGYF丶5 小时前
【PCIe总线】 -- PCI、PCIe相关实现
linux·嵌入式·pcie·pci