在虚拟机中安装Centos7之后使用yum update等命令出现错误:
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock57error was
14: curl#6 - “Could not resolve host: mirrorlist.centos.org1; Unknown error”
One of the configured repositories failed (Unknown),
and yum doesn’t have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work “fix” this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Disable the repository, so yum won't use it by default. Yum will then
just ignore the repository until you permanently enable it again or use
--enablerepo for temporary usage:
yum-config-manager --disable <repoid>
4. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
方法一:
在网上搜索之后,发现一种较为普遍的方法,就是修改dns设置
vi /etc/resolv.conf 或者 echo "nameserver 8.8.8.8" >> /etc/resolv.conf
修改成如上样子。
保存退出后使用service network restart命令重启网卡。
方法二:
首先使用 ping linuxcommand.org查看网络通不通。
如果不通的话就要设置一下VMware Funsion中Centos7的网络配置
首先打开虚拟机中的网络适配器选项,选择此网络适配器配置为NAT模式
在Mac中打开终端获取mac机器中vmnet8的gateway ip
cat /Library/Preferences/VMware Fusion/vmnet8/nat.conf
出现
cat: /Library/Preferences/VMware: No such file or directory
cat: Fusion/vmnet8/nat.conf: No such file or directory
我们先 cd /Library/Preferences
键入ls命令
会发现其中有VMware Funsion
但是 cd VMware Fusion却显示no such file or directory
现在我们先输入 cd VMware 再按tab健
会发现自动补全之后多了与现实不一样的符号,这应该是编码的问题,下面我们直接enter进入
之后cat vmnet8/nat.conf
寻找# NAT gateway address一行
记录此ip。
在Mac的网络偏好设置中,选择高级,在TCP/IP选项中记录网络掩码
在DNS选项中,记录本机DNS服务器
之后进入虚拟机中的Centos系统
进入 /etc/sysconfig/network-scripts找到其中一个叫ifcfg-ens33的文件
使用 vi ifcfg-ens33 命令编辑此文件,
其中的NETMASK为Mac的网络掩码,DNS1为Mac的DNS服务器地址,GETWAY为Mac的gateway ip。
配置成如上形式。
保存并退出后,yum update 命令就可以执行了!
方法三:
通过改变虚拟机的网络设置。网络连接改成“桥接”模式即可。