至尊技术网 - yum install
type: channel
link: https://www.zzwws.cn/tag/yum-install/
items: 【CentOS7】yum 报错：Could not retrieve mirrorlist http://mirrorlist.centos.org

【CentOS7】yum 报错：Could not retrieve mirrorlist http://mirrorlist.centos.org
type: item
date: 2025-01-23T18:02:00+08:00
description: 前言用yum install 命令去安装一些linux插件时报错，找了很久才解决，踩了很多坑，希望你们也不要踩，既不是大家搜索的网络问题，ping www.baidu.com可以通、DNS也设置了；一、报错如下1、报错内容如下[root@node1 yum.repos.d]# yum install ifconfig Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://mirrorlist.centos.org?arch=x86_64&release=7&repo=sclo-sclo error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error" 2、原因我们的服务器没法访问镜像的网络，所以我们需要配置正确的镜像源；二、解决流程1、进入 /etc/yum.repos.d文件目录；cd /etc/yum.repos.d 2、备份文件备份这三个文件就行了（注意！！很多人只有 CentOS-Base.repo 文件，没有后两个，这也没问题，有几个备份几个，不用额外创建！）3、编辑CentOS-Base.repo 文件（必选）！！！ 警告，在编辑文件的时候，你肯定是复制黏贴下面的内容的。但是，vim 编辑器会有个黏贴反应时间，所以大概率你在黏贴了内容之后，最开头的内容会缺少 1-5 个字符，你需要手动补全，下面的编辑也是一样 ！！！vi /etc/yum.repos.d/CentOS-Base.repo 全选替换：# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # [base] name=CentOS-$releasever - Base baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates baseurl=https://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #contrib - packages by Centos Users [centosplus] name=CentOS-$releasever - Plus baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://mirrors.aliyun.com/cento…