我的流浪汉昨晚工作得很好。我刚打开电脑,点击《流浪者》,这就是我得到的:

==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2222 (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
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...

有人吃过这个吗?vagrant在网络上还没有被广泛报道,我也找不到发生这种情况的原因。


当前回答

对我来说有用的是从BIOS允许64位操作系统(Ubuntu 13.10)上的64位虚拟化。

其他回答

从virtualbox界面,我首先在“CD”上启动,并禁用硬盘启动。因此,它是从CD iso引导的,显然不是在预期的机器上…我希望这能有所帮助。我希望它也能让某人微笑……PEBCAK。

我解决这个问题的方法在这篇文章中没有提到,所以我把细节贴在这里,以防它能帮助到其他人。

造成这种情况的原因是,在机器启动后,流浪汉无法登录机器。造成这种情况的原因有很多,正如本文中提到的,比如机器无法一直启动,或者iptables防火墙阻止SSH。

在我的例子中,问题是我无意中设置了一个“private_network”,它的IP地址与内置的VirtualBox NAT网络(在我的例子中是10.0.2.0/24)在同一个子网中。这打乱了机器的NAT网络(但没有任何地方显示错误),由于vagrant通过NAT网络连接,因此即使机器正在运行且没有启用防火墙,它也无法连接。

Vagrant.configure("2") do |config|
  config.vm.network "private_network", ip: "10.0.2.31"
end

解决办法是更新我的VagrantFile,并使用一个与VirtualBox的NAT网络不冲突的“private_network”IP。

Vagrant.configure("2") do |config|
  config.vm.network "private_network", ip: "10.0.4.31"
end

如果您正在使用包装层(如Kitchen CI),并且正在运行32b主机,则必须抢先安装Vagrant盒子。它们的默认提供程序是二进制文件的opscode“家族”。

所以在厨房创建default-ubuntu-1204之前,请确保您使用:

vagrant box add default-ubuntu-1204 http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04-i386_chef-provisionerless.box

如果您的主机不支持字大小虚拟化,则使用32b映像

对我有帮助的是在BIOS中启用虚拟化,因为机器无法启动。

我也有同样的问题。我认为问题可能是SSH密钥(错误的文件定位或其他东西,但我检查了很多次),但你可能总是在配置部分添加用户名和密码(不使用SSH密钥)和运行gui,所以Vagrantfile中的代码应该看起来或多或少如下:

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.ssh.username = "vagrant"
  config.ssh.password = "vagrant"

   config.vm.provider "virtualbox" do |vb|
     vb.gui = true
   end
end

In my case even if GUI was displayed I got black screen (no errors or possibility to login or anything else) and in console I got the Error: Connection timeout. Retrying... many times. I made sure I had VT-x (virtualization) enabled in BIOS, I checked many combinations of versions of both Virtual Box and Vagrant together and many Vagrant boxes (for some of them I didn't have black screen in GUI but still have connection problems). Finally I've updated VirtualBox and Vagrant again to the last versions and the problem still occurred.

最关键的是在运行vagrantup(使用Vagrantfile中的GUI)后,在VirtualBox中查看图标,如下图所示

虽然我在VirtualPC中没有错误(没有VT-x未启用的警告),但我的V图标是灰色的,所以这意味着VT-x被禁用。正如我说的,我一直在我的BIOS中启用它。

Finally I realized the problem might by HYPER-V which I also installed and enabled to test sites on older Internet Explorer. I went to Windows Control Panel -> Programs and functions / Software and choose from the menu on left Turn on or Turn off Windows functions (hope you will find those, I use Polish Windows so don't know exact English names). I turned off Hyper-V, restarted PC and after running Virtual Box and vagrant up I finally had no errors, in GUI I have login screen and my V icon stopped to be gray.

我浪费了很多时间来解决这个问题(和许多电脑重启),所以我希望这可能对任何在Windows上有问题的人有帮助-确保你在控制面板中关闭了Hyper-V。