【CentOS7.6】yum 报错:Could not retrieve mirrorlist http://mirrorlist.centos.org

news/2024/7/8 6:54:18 标签: yum, linux, centos

一、报错

1.报错内容如下

在使用 yum makecache 命令时报错,在 yum install -y xxx 的时候报错等等

[root@hcss-ecs-a901 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org?arch=x86_64&release=7&repo=sclo-rh error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"


 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64

2.原因分析

我们的服务器没法访问外面的网络,所以我们需要配置镜像源

二、解决

1.进入目录

先进入目录 /etc/yum.repos.d

cd /etc/yum.repos.d
2.打开 xftp

在这里插入图片描述

3.备份文件

备份这三个文件就行了
在这里插入图片描述

4.编辑 CentOS-Base.repo 文件

!!! 警告,在编辑文件的时候,你肯定是复制黏贴下面的内容的。但是,vim 编辑器会有个黏贴反应时间,所以大概率你在黏贴了内容之后,最开头的内容会缺少 1-5 个字符,你需要手动补全,下面的编辑也是一样 !!!
编辑 CentOS-Base.repo 文件:

vi /etc/yum.repos.d/CentOS-Base.repo

替换内容为:

[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

[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

[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

[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
5.编辑 CentOS-SCLo-scl-rh.repo 文件

编辑 CentOS-SCLo-scl-rh.repo 文件:

vi /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo

替换内容为:

[centos-sclo-rh]
name=CentOS-$releasever - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/rh/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
6.编辑 CentOS-SCLo-scl.repo 文件

编辑 CentOS-SCLo-scl.repo 文件:

vi /etc/yum.repos.d/CentOS-SCLo-scl.repo

替换内容为:

[centos-sclo-sclo]
name=CentOS-$releasever - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/sclo/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
yum__133">7.清理 yum 缓存
yum clean all
yum__139">6.重新生成 yum 缓存
yum makecache

请注意!如果在你之后的 yum install 过程中发生了 GPGKEY 报错,请参考这篇博客:
请注意!如果在你之后的 yum install 过程中发生了 GPGKEY 报错,请参考这篇博客:
请注意!如果在你之后的 yum install 过程中发生了 GPGKEY 报错,请参考这篇博客:

https://blog.csdn.net/qq_43768851/article/details/140113001?spm=1001.2014.3001.5501

三、结果

yum_makecache__150">1.再次 yum makecache 的结果如下

圆满成功

在这里插入图片描述


http://www.niftyadmin.cn/n/5536679.html

相关文章

sql-语句

文章目录 SQL语句的学习sql是什么sql的内置命令sql的种类sql mode库&#xff0c;表属性介绍&#xff1a;字符集&#xff0c;存储引擎列的数据类型&#xff1a;数字&#xff0c;字符串&#xff0c;时间列的约束DDL: 数据定义语言库表 Online DDL(ALGORITHM) *DML :数据操纵语言资…

MySQL高级-MVCC-基本概念(当前读、快照读)

文章目录 1、MVCC基本概念1.1、当前读1.1.1、创建表 stu1.1.2、测试 1.2、快照读 1、MVCC基本概念 全称Multi-Version Concurrency Control&#xff0c;多版本并发控制。指维护一个数据的多个版本&#xff0c;使得读写操作没有冲突&#xff0c;快照读为MySQL实现MVCC提供了一个…

安装基于Ubuntu的Zorin OS

目录 前言Zorin OS 介绍准备工具硬件&#xff08;自己准备&#xff09;软件&#xff08;我会在文末提供链接&#xff09; 安装1. 磁盘分区2. 关闭Secure Boot&#xff08;可选&#xff09;3. 关闭RST4. 下载&写U盘5. U盘加载系统6. 正式安装7. 重启 总结下载链接花絮 本文由…

Eclipse 菜单:深入解析与高效使用技巧

Eclipse 菜单:深入解析与高效使用技巧 Eclipse 是一款广泛使用的集成开发环境(IDE),它为Java、C++、PHP等编程语言提供了一个强大的开发平台。Eclipse 的菜单是其用户界面的一部分,提供了丰富的功能和选项,以帮助开发者更高效地工作。本文将深入解析 Eclipse 的菜单系统…

关于Mac mini 10G网口的问题

问题: 购入一个10G网口的Mac mini M2&#xff0c;将其和自己的2.5G交换机连接&#xff0c;使用共享屏幕进行远程操作的过程中出现了频率极高的卡顿&#xff0c;几乎是几秒钟卡一下&#xff0c;使用ping进行测试发现卡的时候就ping不通了。测试使用Mac mini的无线网和雷电转2.5G…

【CUDA】 矩阵乘向量 matVecMul

Matrix - Vector Multiplication 矩阵-向量乘法是线性代数中的基本操作。它用于将一个矩阵与一个向量相乘。乘法的结果是与输入向量大小相同的向量。 矩阵和向量的乘法如图1所示。 图1 基础kernel与共享内存kernel 执行矩阵-向量乘法的基础kernel是使用单个线程执行输出向量…

网站UI:我只负责漂亮,实现的事情交给前端开发。

网页UI的美观性对于用户体验和网站的成功至关重要&#xff0c;以下是几个原因&#xff1a; 吸引用户&#xff1a;美观的网页UI可以吸引用户的注意力&#xff0c;使用户对网站产生兴趣并留下深刻印象。用户更有可能在美观的界面上停留更长时间&#xff0c;探索网站的功能和内容…

宝塔面板Nginx的https301跳转http

宝塔面板Nginx的https301跳转http&#xff1a; 登录宝塔面板&#xff1a;进入你的宝塔面板管理界面。 选择网站管理&#xff1a;在左侧菜单中&#xff0c;点击“网站”&#xff0c;然后选择你需要进行重定向的网站。 配置网站设置&#xff1a;在所选网站的管理界面中&#x…