centos源配置

一、问题描述

初次安装好cents系统后,执行yum install wget命令报错:

[root@localhost ~]# yum install -y wget
CentOS Linux 8 - AppStream 0.0 B/s | 0 B 00:01 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=stock [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=stock [Could not resolve host: mirrorlist.centos.org]

二、当前环境

 Linux环境:CentOS8.5.2111

三、解决方案(依次执行以下命令)

1.备份配置

cd /etc
mv yum.repos.d/ yum.repos.d.bak
mkdir yum.repos.d
cd yum.repos.d

2.下载阿里云CentOS源

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

3.非阿里云用户修改

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
 

4.清除缓存,建立缓存

yum -y clean all
yum -y makecache
yum repolist # 查看yum仓库信息
 

5.验证命令(我当前是已经安装过了,所以提示Package wget-1.19.5-10.el8.x86_64 is already installed)

[root@localhost xx]# yum install wget
Last metadata expiration check: 0:16:12 ago on Wed 12 Mar 2025 09:01:30 AM CST.
Package wget-1.19.5-10.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!


四、致谢

我参考了 @林木无可栖 博主的centos源配置部分;

感谢 @林木无可栖 博主的无私奉献,博客地址:CentOS-8.5.2111 Boot版安装流程(配置yum源、配置远程连接、服务自启动)_centos8.5-优快云博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值