【发布时间】:2019-02-28 07:36:01
【问题描述】:
首先,我意识到这是一个常见的错误消息,有几个不同的原因和解决方案,但到目前为止我发现没有任何工作。我有 Vagrant 2.1.5 和 Virtualbox 5.2.18,在 Windows 10 上运行。
我正在用一个非常简单的 Vagrantfile 测试 Vagrant:
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
end
运行 vagrant up 然后给出典型的“等待机器启动时超时”错误:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' is up to date...
==> default: Setting the name of the VM: vargrantTest_default_1537805339381_15444
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
我尝试过的事情:
- 确保在 BIOS 中启用虚拟化
- 增加 vagrantfile 中的引导超时
- 确保 Virtualbox 中的 VM 网络设置正确(已连接电缆的 NAT 适配器)
- 使用
vb.gui = true观察VM 启动。它可以正常启动并在登录屏幕上等待。 - 在 vagrant up 上使用 --debug 标志。这并没有给出我发现的任何明显错误,尽管在超时之前它会运行
VBoxManage showvminfo --machinereadable数百次,导致日志文件超过 80k 行。
还有其他几件事我忘了写下来。我没有想法,而且对 Vagrant 还很陌生,所以我真的不知道下一步的故障排除是什么。任何帮助将不胜感激。
编辑:不知道为什么我不打算自己做,但 Marco 给了我尝试直接 ssh 到 VM 的想法。我尝试使用 Vagrant 创建的“/.vagrant.d/insecure_private_key”中的密钥文件这样做,但它超时了。然后,我尝试简单地 ping 虚拟机,但这样做看似随机混合了“请求超时”和“目标主机无法访问”,因此某处(我的机器、虚拟机或 Virtualbox)可能存在更大的网络问题。我不知道。
【问题讨论】:
-
感谢您使用最新的 Vagrant 和 VirtualBox!我可以想出两个你可以做的测试。如果您独立于 Vagrant 使用 VirtualBox 会发生什么?如果在收到上述错误后,您尝试 ssh 进入盒子会发生什么?为此,您可以使用“vagrant ssh-config”,然后将输出调整为 Putty 或您在 Windows 上使用的 SSH 客户端。
-
单独使用 Virtualbox 可以正常工作,但似乎可能存在网络问题,因为尝试直接 ssh 到 VM 会导致超时,并且 ping 它会给出“无法访问目标”。我会再调查一下,谢谢马尔科。
-
你试过用 {username: vagrant, password: vagrant} 在屏幕上登录吗?
标签: vagrant centos7 vagrantfile vagrant-windows