CentOS 7官方停止维护yum源安装报错,如何修改yum源为阿里云

centos7,2024年6月30日停止维护(EOL,End Of Life),自此时间后Centos7将无法使用Centos社区官方提供的yum源下载软件,当使用默认源下载时会报如下错误:

curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
...
Cannot find a valid baseurl for repo: base/7/x86_64
或者
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; Unknown error"

表示官方软件仓库的域名地址(mirrorlist.centos.org)已经被删除了解析,已无法访问,建议用户更换其他系统,如果您一定要使用CentOS 7.x,那么只能将系统的yum源更换为第三方yum源。

以下是将yum源更换为阿里云的教程。

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache

如果你是完全mini安装的centos还没有 curl工具,可以尝试以下命令然后再 clean和make。

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

[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.aliyun.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.aliyun.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

对于centos 8 可以进行如下操作
sudo rm -rf /etc/yum.repos.d/*

sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

sudo yum clean all

sudo yum makecache
===============
sudo cp -r /etc/yum.repos.d /etc/yum.repos.d.bak #先进行备份

sudo mv /etc/yum.repos.d.bak /etc/yum.repos.d  #如果删除后有错误需要进行恢复

想了解更多关于CentOS 7官方停止维护yum源安装报错,如何修改yum源为阿里云的内容,请扫微信
或微信搜索jiemingpan

本文链接:http://www.soufuzi.com/jianzhan/3104

(0)
上一篇 2025-05-10 18:16:11
下一篇 2025-05-10 18:16:11

相关推荐

  • 阿里云对象存储OSS流量价格

    对象存储OSS并不是所有流量都收费,用户从本地上传文件到OSS产生的流量是免费的,内网产生的流量也是免费的,只有公网产生的出方向流量才收费,例如用户使用公网从OSS下载文件到本地产生的流量才收费。对象存储OSS流量有两种计费模式:一种是按量付费,根据实际使用的流量,乘以流量单价计算流量费用;另一种是包年包月通过购买流量包的形式来抵扣产生的流量。 关于OSS:https://dashi.aliyun.com/site/cloud/oss

    2023-08-10 13:34:44
  • 外贸合同的注意事项有哪些?

    外贸合同是确保交易顺利进行的基础,签订合同时需要注意以下几点: · 明确价格和付款方式:包括货币种类、支付渠道及具体的付款时间节点。 · 详细的交货条件:确定货物的交货时间、地点及运输方式。 · 争议解决条款:事先规定好万一发生争议时的解决办法,如选择仲裁或诉讼方式。 一个全面且明确的合同能够帮助减少后期的纠纷和风险。

    2025-02-17 00:14:27