CentOS配置了镜像源之后依旧下载元数据失败

java 复制代码
// 切换到root用户
su root

备份原有的镜像源

bash 复制代码
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

使用阿里云镜像源

bash 复制代码
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

这是清华的镜像源

bash 复制代码
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/help/centos-vault/8.5.2111/CentOS-Base.repo

执行到清理缓存时提示失败

java 复制代码
[root@192 lj]# sudo yum clean all
Repository extras is listed more than once in the configuration

错误表明在 YUM 配置文件中,extras 仓库被重复定义了多次。这可能是由于多个 .repo 文件中都定义了 extras 仓库,并且某些旧的或默认的配置可能仍然指向官方的 mirrorlist.centos.org

运行以下命令,列出 /etc/yum.repos.d/ 目录下的所有 .repo 文件,挨个检查并清理重复的仓库定义

bash 复制代码
ls /etc/yum.repos.d/

逐个检查这些文件,确保没有重复定义的仓库(如 extras、appstream 等)

bash 复制代码
cat /etc/yum.repos.d/CentOS-Base.repo
cat /etc/yum.repos.d/CentOS-Linux-AppStream.repo
cat /etc/yum.repos.d/CentOS-Linux-Extras.repo
、
、
、

删掉或者注释掉CentOS的仓库定义,只保留阿里或者清华的镜像

bash 复制代码
vim /etc/yum.repos.d/CentOS-Base.repo
输入 i 进入编辑模式
修改完后,按Esc键退出编辑模式
按 :qw! 四键保存并退出

全部检查完之后,运行以下命令清理缓存并重新生成缓存

bash 复制代码
sudo yum clean all
sudo yum makecache

尝试安装一个软件包,验证配置是否成功。

bash 复制代码
sudo yum install bash-completion
相关推荐
SkyWalking中文站1 小时前
认识 Horizon UI · 11/17:运行时规则与实时调试
运维·监控·自动化运维
阿里云大数据AI技术20 小时前
阿里云 EMR AI 助手正式发布:从问答工具到全栈智能运维助手
运维·人工智能
orion572 天前
Missing Semester Class1:course overview and introduction of shell
linux
SkyWalking中文站2 天前
认识 Horizon UI · 6/17:Trace 探索器
运维·监控·自动化运维
用户120487221612 天前
Linux驱动编译与加载
linux·嵌入式
火车叼位2 天前
写给初级开发者:SSL、SSH、HTTPS 与证书体系全解析
运维
用户805533698032 天前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户805533698032 天前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
小猿姐2 天前
唯品会大规模数据库云原生实践:基于 KubeBlocks 管理数千实例的统一运维之路
运维·elasticsearch·云原生
七歌杜金房3 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac