首页 > 系统相关 >CentOS 7 yum无法使用解决方法Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=

CentOS 7 yum无法使用解决方法Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=

时间:2024-07-29 21:08:44浏览次数:13  
标签:retrieve centos CentOS http repo mirrorlist org

在centos7中使用yum命令事后报错:

Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"

image

问题原因

出现这个错误是因为使用的 CentOS 7 仓库已经被归档,当前的镜像地址无法找到所需的文件。CentOS 7 的官方支持已经结束,部分仓库已被移至归档库。这导致了你的 yum 命令无法找到所需的元数据文件。CentOS 7 的官方仓库在 2024 年 6 月 30 日之后已经停止维护。因此,使用最新的 CentOS 7 官方仓库可能会遇到问题。

解决方法

进入/etc/yum.repos.d目录下找到 CentOS-Base.repo
进入目录:

cd /etc/yum.repos.d

image
之后依次执行:

cp  CentOS-Base.repo   CentOS-Base.repo.backup
vi 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
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#$baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
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

然后wq保存下,依次执行:

sudo yum clean all
sudo yum makecache

之后等待加载:
image

阿里云镜像源

以下两个命令都可以,执行完成后进入/etc/yum.repos.d

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

然后执行:

 cat CentOS-Base.repo

image
看着镜像是阿里云的即可。 建议在执行下

sudo yum clean all
sudo yum makecache

欢迎关注公众号:愚生浅末

标签:retrieve,centos,CentOS,http,repo,mirrorlist,org
From: https://www.cnblogs.com/kohler21/p/18331060

相关文章

  • 关于centos7yum安装出错问题
    报错信息[root@192~]#yuminstall-ynginx已加载插件:fastestmirrorLoadingmirrorspeedsfromcachedhostfileCouldnotretrievemirrorlisthttp://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stockerrorwas14:curl#6-"Couldno......
  • 【新手|非常简单】VMWare在NAT模式下为Centos7虚拟机配置静态IP
    检查VMWare的网络设置点击VMWare菜单栏中的“编辑”,点击“虚拟网络编辑器”检查一下NAT模式那一条,和我这里的设置是不是一样的(IP可能会不一样),我这里的设置是默认设置。如果不确定,可以点击“还原默认设置”。(你也可以尝试按着截图中的设置调)检查虚拟机的网络连接右键虚拟机,......
  • Centos7系统根分区空间小,home空间大。怎么删除home分区 增加到root
    查看分区df-Th删除home分区或注释掉vi/etc/fstab卸载home分区umount /home查看逻辑分区lvsca移除/home的lv分区lvremove/dev/mapper/centos-home  查看一下vg设置vgdisplay可以看到空闲出来的空间把空闲出来的全部拓展到根目录下lvextend-l+100%free......
  • Centos中修改Docker镜像源:解决error pulling image configuration:download failed a
    场景在进行拉取镜像时提示:errorpullingimageconfiguration:downloadfailedafterattempts=6:dialing... 这是因为镜像源无法连接和使用了。但是之前已经配置过国内docker的镜像源了。是因为自2024年6月份左右国内镜像源大部分失效,原因自行探索。所以记录下如何修......
  • CentOS安装MySQL
    参考文章【CentOS安装mysql简单教程】https://blog.csdn.net/qq_50523945/article/details/131069683【运维系列:centos7yum安装使用时提示cannotfindavalidbaseurlforrepo:base/7/x86_64的解决方法(亲测有效☆)】https://blog.csdn.net/weixin_54626591/article/detai......
  • centos7.9 安装Hyperf 环境
    安装php7.4cat/etc/redhat-releaseyuminstallepel-releaserpm-Uvhhttps://rpms.remirepo.net/enterprise/remi-release-7.rpmyuminstall-yyum-utilsyum-config-manager--enableremi-php74yuminstall-yphpphp-fpmphp-cliphp-fpmphp-mysqlndphp-zipphp-d......
  • Centos7下Docker搭建Matomo
    1.docker安装和启动wgethttps://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo-O/etc/yum.repos.d/docker-ce.repoyuminstalldocker-ce-ysystemctlstartdockersystemctlenabledockersystemctlstatusdocker2.配置镜像加速器 针对Docker客户端版......
  • docker启动MySQL容器演示(centos)
    环境配置vboxcentos7.9docker(已经配置阿里镜像源)首先拉取MySQL镜像dockerpullmysql:版本号版本号不打也可以,会默认下载最新版(latest)下载后使用dockerimages查看镜像如图我下载了MySQL5.7/8.0/latest版本然后执行下面的命令就可以启动(运行)容器了dockerrun-d-......
  • linux centos7环境下通过rpm部署MySQL
    一、环境准备环境:centos7,确保虚拟机内存足够,不然无法上传数据包和解压mysql包:mysql-8.0.25-1.el7.x86_64.rpm-bundle.tar这个包去MySQL官网可以下载,此链接可以直达:https://downloads.mysql.com/archives/community/二、打开远程连接,连上自己的虚拟机1.连上自己的虚拟机后......
  • CentOS配置NTP服务
     更改配置文件[root@Controller~]#vim/etc/chrony.conf重启服务并设置为开机自启动[root@Controller~]#systemctlrestartchronyd.service[root@Controller~]#systemctlenablechronyd.service在另一台CentOS测试更改配置文件[root@Compute~]#vim/etc......