Centos8安装软件失败更换镜像源

问题

Centos 8上安装git,报错如下:

sudo dnf install git -y
Repository extras is listed more than once in the configuration
CentOS Linux 8 - AppStream                                                                          0.0  B/s |   0  B     00:00    
Errors during downloading metadata for repository 'appstream':
  - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container [Could not resolve host: mirrorlist.centos.org]

原因

由于CentOS 8已经停止更新,官方镜像可能不再可用。可以考虑更换为 Vault 仓库或使用其他社区维护的镜像源

解决方案

1. 备份现有的 .repo 文件

首先,备份当前的 .repo 文件,以防需要恢复。

sudo cp -r /etc/yum.repos.d/ /etc/yum.repos.d.bak

2. 下载阿里云的 CentOS 8 镜像源文件

使用以下命令下载阿里云的 CentOS 8 镜像源配置文件:

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

需要确保/etc/yum.repos.d/目录下的所有文件中mirrorlist url都被替换:
在这里插入图片描述
在这里插入图片描述

3. 清除缓存并更新缓存

sudo dnf clean all
sudo dnf makecache

4. 安装Git

sudo dnf install git -y
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值