centos更换镜像源

下载失败

java 复制代码
[root@192 opt]# sudo yum install -y yum-utils
已加载插件:fastestmirror, langpacks
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; 未知的错误"


 One of the configured repositories failed (未知),
 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 镜像源。


简单回答

  • 安装这个包需要镜像源吗?需要 。因为 yum-utils 这个软件包并不在本地,需要从远程的 yum 仓库(镜像源)下载安装。

  • 你现在在干什么? → 你正在通过 yum 命令从镜像源下载并安装 yum-utils

打个比方

把 yum 想象成 手机应用商店

场景 类比
yum install yum-utils 你在应用商店搜索并下载一个 App
镜像源(仓库) 应用商店的服务器,存放着所有 App 的安装包
报错 Could not resolve host 你的手机连不上应用商店的服务器(网络或域名解析问题)

所以,没有镜像源,yum 就无法下载任何软件包 ,包括 yum-utils

你的情况

text

复制代码
你 → 执行 yum install → 访问镜像源服务器 → 连不上(DNS解析失败)→ 报错

你正在使用的镜像源是 CentOS 官方源(mirrorlist.centos.org),但因为:

  • DNS 没配好,或者

  • 官方源已停服(CentOS 7 已 EOL)

所以下载失败了。


结论

你需要先修好镜像源 (比如换成阿里云源),然后才能成功安装 yum-utils。修好后,yum 会从新的镜像源下载这个包,就成功了。

更换阿里云 vault

这是 CentOS 7 已停服,官方源 mirrorlist.centos.org 失效了。先改成可用镜像源,再继续装。

java 复制代码
mkdir -p /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/

cat > /etc/yum.repos.d/CentOS-Base.repo <<'EOF'
[base]
name=CentOS-7 - Base
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/os/$basearch/
gpgcheck=0
enabled=1

[updates]
name=CentOS-7 - Updates
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/updates/$basearch/
gpgcheck=0
enabled=1

[extras]
name=CentOS-7 - Extras
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/extras/$basearch/
gpgcheck=0
enabled=1
EOF

yum clean all
yum makecache
相关推荐
爱喝水的鱼丶6 小时前
SAP-ABAP:ABAP 用户出口参数传递与上下文获取:SAP 标准数据读取与交互逻辑实现
运维·性能优化·交互·sap·abap·经验交流·出口
IT大白鼠6 小时前
PentestGPT作为AI运维编排工作流自动化底座的技术架构与应用价值评估
运维·人工智能·自动化·pentestgpt
M78佐菲7 小时前
c语言学习笔记:排序与查找方法整理
linux·c语言·笔记·学习·算法
ltl7 小时前
QUIC 协议拆解(上):为什么 TCP 改不动了
linux
j7~7 小时前
【Git】《Git 系列指南(二):Git基本操作与 reset 三种模式》
运维·git·git安装·git基本操作·git配置·创建git仓库·git reset三种模式
zzzll11117 小时前
n8n 工作流自动化平台入门指南
运维·自动化
Hrain-AI8 小时前
Anthropic oncall-kit 开源拆解:运维 Agent 落地范式的四基石与权限边界
运维·人工智能·开源
HXDGCL8 小时前
从“转盘困局”到“直线破局”:华创力科技PTS精密分度输送系统如何重塑自动化产线
运维·科技·自动化
戴西软件9 小时前
国内有哪些智能化RPA工具?——从“录数据”到“做判断”,国产数字员工正在重新定义自动化
运维·自动化·rpa
Linux-lucky9 小时前
28-Linux学习之旅之Maven与Nexus制品库
linux·运维·学习·nginx·tomcat·maven