【问题标题】:Vagrant/virtualbox no SSH connection and timeout (Windows)Vagrant/virtualbox 没有 SSH 连接和超时(Windows)
【发布时间】:2017-08-29 08:48:20
【问题描述】:

我正在尝试设置这台机器:https://github.com/ByteInternet/hypernode-vagrant

当我执行vagrant up 时,出现以下错误:Timed out while waiting for the machine to boot.

错误的完整上下文:

$ vagrant up
Bringing machine 'hypernode' up with 'virtualbox' provider...
==> hypernode: Will use PHP 7. If you want PHP 5.5 instead change the php version in local.yml.
==> hypernode: Checking if box 'hypernode_php7' is up to date...
==> hypernode: Clearing any previously set forwarded ports...
==> hypernode: Clearing any previously set network interfaces...
==> hypernode: Preparing network interfaces based on configuration...
hypernode: Adapter 1: nat
hypernode: Adapter 2: hostonly
==> hypernode: Forwarding ports...
hypernode: 80 (guest) => 8080 (host) (adapter 1)
hypernode: 3306 (guest) => 3307 (host) (adapter 1)
hypernode: 22 (guest) => 2222 (host) (adapter 1)
==> hypernode: Running 'pre-boot' VM customizations...
==> hypernode: Booting VM...
==> hypernode: Waiting for machine to boot. This may take a few minutes...
hypernode: SSH address: 127.0.0.1:2222
hypernode: SSH username: vagrant
hypernode: 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.

当我手动启动虚拟机时,我可以看到网络没有正常工作。没有联系。当我将虚拟机的设置更改为桥接网络时,网络确实可以工作。但是流浪者被配置为NAT。因此,我在设置或 vagrant 文件中所做的任何更改似乎都会重新设置。

我在两台不同的 PC 上试用了 Vagrant 1.9.3、1.9.2 和 1.9.0。我正在使用 Virtualbox 5.1.18。当我用“NAT”过滤日志时看到以下错误(这不是完整的日志,只是一小部分)

00:00:00.575454 SUP: Loaded VMMR0.r0 (C:\Program     Files\Oracle\VirtualBox\VMMR0.r0) at 0xfffff80c897b0000 - ModuleInit at     fffff80c897d3590 and ModuleTerm at fffff80c897d3a80 using the native ring-0 loader
00:00:01.681747 Driver = "NAT" (cb=4)
00:00:01.962037 SUP: Loaded VBoxDDR0.r0 (C:\Program Files\Oracle\VirtualBox\VBoxDDR0.r0) at 0xfffff80c898d0000 - ModuleInit at         0000000000000000 and ModuleTerm at 0000000000000000 using the native ring-0 loader
00:00:02.196495 NAT: Guest address guess set to 10.0.2.15 by initialization
00:00:02.204465 NAT: DNS#0: 192.168.178.1
00:00:02.271317 NAT: Failed to redirect TCP 127.0.0.1:2222 -> 0.0.0.0:22 (Unknown error)
00:00:02.271732 NAT: Failed to redirect TCP 0.0.0.0:3307 -> 0.0.0.0:3306 (Unknown error)
00:00:02.272033 NAT: Failed to redirect TCP 0.0.0.0:2200 -> 0.0.0.0:80 (Unknown error)
00:00:09.976199 NAT: Link up
00:00:39.428974 NAT: DHCP offered IP address 10.0.2.15
00:00:39.429404 NAT: DHCP offered IP address 10.0.2.15
00:03:02.167191 NAT: DHCP offered IP address 10.0.2.15
00:03:02.167820 NAT: DHCP offered IP address 10.0.2.15
00:07:58.531621 NAT: Zone(nm:mbuf_cluster, used:0)
00:07:58.532221 NAT: Zone(nm:mbuf_packet, used:0)
00:07:58.532232 NAT: Zone(nm:mbuf, used:1)
00:07:58.532419 NAT: Zone(nm:mbuf_jumbo_pagesize, used:0)
00:07:58.532961 NAT: Zone(nm:mbuf_jumbo_9k, used:0)
00:07:58.533255 NAT: Zone(nm:mbuf_jumbo_16k, used:0)
00:07:58.533424 NAT: Zone(nm:mbuf_ext_refcnt, used:0)
00:07:58.536529 Changing the VM state from 'DESTROYING' to 'TERMINATED'

我该如何解决或调试这个问题?

更新

最近几天我也尝试了下面列出的不同版本的 virtualbox 和 Vagrant,但没有任何结果:

  • Virtualbox 5.0.18
  • Virtualbox 5.0.20
  • Virtualbox 5.0.36
  • 流浪者 1.9.3

我也试过另一个盒子,也有同样的问题。所以看起来不是盒子而是主机。

此外,我在 Windows 7 机器上尝试了设置,结果完全相同。我想我在配置中遗漏了一些东西,但我不知道是什么,因为没有明确的指南可以让它在 Windows 机器上运行。

更新 2: 我尝试的机器可能不支持这种设置吗?我尝试在 BIOS 中寻找虚拟化选项。

更新 3: 当我从主机到访客执行 ssh -v 127.0.0.1 -p 1222 时,出现以下错误。 SSH 服务已在来宾上启动并运行。我检查了sshd service status

$ ssh -v 127.0.0.1 -p 1222
OpenSSH_7.3p1, OpenSSL 1.0.2k  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 1222.
debug1: connect to address 127.0.0.1 port 1222: Connection refused
ssh: connect to host 127.0.0.1 port 1222: Connection refused

更新 4:我无法从访客机器上 ping 任何互联网 IP 或域。

更新 5: 已解决!切换到 Linux 有一段时间了。有史以来最好的决定:D

【问题讨论】:

    标签: vagrant virtualbox nat


    【解决方案1】:

    当我在 Windows 10 Pro 上出现此错误时:

        ...
        homestead: SSH auth method: private key
    Timed out while waiting for the machine to boot. ...
    ...
    

    我发现我需要做的就是在命令行上运行时打开 VirtualBox GUI 并选择 VM

    vagrant reload --provision

    如果 GUI 关闭,它会反复超时,引发上述错误。

    如果 GUI 已打开,则该过程会正常继续,没有错误,一切都开始工作。

    我还发现有时在自动重启 Windows 后,我的网络适配器没有安装VirtualBox NDIS6 Bridged Networking Driver,这也可能导致此错误。

    这可以通过打开网络连接属性并点击Install -> Service -> Oracle Corporation -> VirtualBox NDIS6 Bridged Networking Driver安装驱动来解决。

    它应该只是出现在列表中,而无需安装驱动程序,但如果您以前从未安装过该驱动程序,那么这可能会让您完成驱动程序安装过程。

    在 Windows 上,包含该驱动程序的文件夹的典型路径如下。您可能不必手动安装任何东西,但如果您这样做,请打开该文件夹,然后打开 Right-Click -> Install VBoxNetFlt.inf 文件。

    %ProgramFiles%\Oracle\VirtualBox\drivers\network\netflt

    【讨论】:

      【解决方案2】:

      首先,将第一个接口更改为 NAT 是正常行为。这是使流浪者工作的必要条件。

      您可以检查两件事: 1) 首选项 > 网络 > nat 网络。 (设置应该是这样的):

      network settings

      2) 确保您已连接虚拟电缆

      cable connected

      3) 也许你可以试试另一个流浪盒子。

      【讨论】:

      • 我的配置为使用“NAT”,请参阅:imgur.com/CAt5LPq.png。还有一个选项“NAT-network”。但是,如果我切换到“vagrant up”,则会出现错误。我的第二个网卡也已配置。喜欢这个imgur.com/JP8qWCu.png。我还没有尝试另一个流浪者盒子。但我知道这个是有效的。我的同事让它在他的 Linux 机器上运行。顺便说一句,屏幕截图中的警告是关于机器使用太多内存的。与网络无关。
      猜你喜欢
      • 2016-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-09
      • 2019-04-26
      • 2016-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多