CentOS 7 yum操作时出现 Could not resolve host: mirrorlist.centos.org 解决记录

开始查询网络上大部分的解决方案是修改DNS为8.8.8.8和8.8.4.4,但是经过多次尝试未果,只能寻找其他解决办法,然后就是想到切换yum源,通过DeepSeek查询到各个源的地址,这里列一下

# 备份原有配置文件
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

# 下载阿里云的镜像源配置文件
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

# 下载清华大学的镜像源配置文件
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/help/centos/centos7.repo

# 下载网易的镜像源配置文件
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo

# 下载华为云的镜像源配置文件
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-7-reg.repo

# 下载腾讯云的镜像源配置文件
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo

# 下载中科大的镜像源配置文件
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.ustc.edu.cn/help/centos7.repo

# 恢复官方镜像源
sudo mv /etc/yum.repos.d/CentOS-Base.repo.backup /etc/yum.repos.d/CentOS-Base.repo

# 清理缓存并生成新的缓存
sudo yum clean all
sudo yum makecache

完成切换yum源后还可能遇到一个问题会弹出提示 “peer‘s certificate issuer is not recognized”

这个就比较简单了 修改一下yum配置就可以了

#打开yum配置文件
vi /etc/yum.conf

#在配置文件中添加、修改配置项为 sslverify 的参数值为false
sslverify=false

#保存后再执行yum操作即可

你可能感兴趣的:(centos,linux,运维)