伤心客 发表于 2024-12-29 23:08:35

题目Could not resolve host: mirrorlist.centos.org; Unknown error【已

在配置Linux下的Nginx服务器前安装gcc时出现该题目。
颠末长时间的search,该题目产生的原因主要有以下几个方面:
1. 虚拟机的网络题目。
2. 镜像网站的配置题目。
3. DNS服务器的设置题目。
一、网络题目解决方案

(一)使用NAT模式
该模式下网络一样平常不会有太大题目,需要留意的是该模式下需要启用DHCP模式。
用以下下令检查网络模式。
配置如下图所示。
cat /etc/sysconfig/network-scripts/ifcfg-ens33 https://i-blog.csdnimg.cn/direct/2fccf7bcf697408fb10a4c51c127d2b9.png
(二)使用主机模式
主机模式配置参考下文:
https://blog.csdn.net/weixin_68727920/article/details/141303586
配置好后重启网络。
三选一
sudo systemctl restart network

sudo nmcli networking on

sudo systemctl restart NetworkManager
二、镜像配置解决方案

(一)按需备份本身原来的镜像配置
此步骤目的在于防止误利用导致镜像毁坏。
mv /etc/yum.repos.d/CentOS-Base.repo /your/path/to/backup-name.repo.backup
(二)确认CentOS版本
法一:
cat /etc/centos-release 法二:
hostnamectl (三)下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
选择本身对应的版本。直接复制运行其中一条指令即可
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
Centos8
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo Centos6
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo (四)手动更新缓存
sudo yum clean all
sudo yum makecache 三、DNS服务器配置解决方案

(一)检查/etc/resolv.conf文件中的 DNS 服务器配置:
cat /etc/resolv.conf
应该看到类似以下内容:
nameserver 8.8.8.8
nameserver 8.8.4.4
如果没有,或 DNS 服务器不正确,可以手动添加 DNS 服务器。使用文本编辑器(如 vim 或 nano)编辑该文件,添加以上两个nameserver。
vim /etc/resolv.conf
参考两位大佬的文章:
【软件工具】CentOS 虚拟机出现 `Could not resolve host: mirrorlist.centos.org` 错误-CSDN博客
解决Could not resolve host: mirrorlist.centos.org; Unknown error_could not resolve host: mirrorlist.centos.org; unk-CSDN博客


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 题目Could not resolve host: mirrorlist.centos.org; Unknown error【已