一、问题描述
初次安装好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-优快云博客