win10上安装的centos7虚拟机 在虚拟机yum安装及yum update命令中 都报错 无法连接,尝试其他镜像等。

网上几篇文章都是复制的一样的关centos防火墙的两个命令

systemctl disable firewalld
systemctl stop firewalld

关闭后依然打不开

尝试把win10的网络防火墙关闭

把yum源由阿里云的换成163的源

更改dns地址为114

问题依旧

尝试了一下curl其中一个报错链接

curl http://mirrors.163.com/centos/7/updates/x86_64/repodata/ac18ef657fb4af51024b7006392ea967d09aeb9c05c13d0f18492f2fc11e77c3-primary.sqlite.bz2

报404 找不到

将http改为https后 成功了

于是将yum源中的http都改为https

vim  /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=https://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=https://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=https://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=https://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
~

再执行

yum makecache
yum update

问题解决

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐