【问题标题】:Vagrant up and reload - default: Warning: Connection timeout. Retrying...Vagrant 启动并重新加载 - 默认值:警告:连接超时。正在重试...
【发布时间】:2015-03-28 11:04:21
【问题描述】:

我现在有一个功能齐全的 vagrant 三个月了,但在过去的三天里,每当我尝试运行 vagrant up 或 vagrant reload 时都会出错。

这是我在运行vagrant reload时遇到的错误

default: Attempting graceful shutdown of VM...
default: Guest communication could not be established! This is usually because
default: SSH is not running, the authentication information was changed,
default: or some other networking issue. Vagrant will force halt, if
default: capable.
default: Forcing shutdown of VM...
default: Clearing any previously set forwarded ports...
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: 80 => 8080 (adapter 1)
default: 22 => 2222 (adapter 1)
default: Running 'pre-boot' VM customizations...
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: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying... 
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.

我正在使用 Elementary OS Luna 并按照一些答案的建议更新了最新版本的 vagrant 和 virtualbox。但问题依然存在。

我已经尝试了大多数流行的解决方案,包括启用 GUI 和 this。我也尝试了here 给出的解决方案,但由于我的虚拟盒子没有登录,所以不能。

但是,GUI 向我展示了这个:

 keys: press S to skip mounting or M for manual recovery

我一一尝试了这两个键,但问题仍然存在。

以前有没有人有过这种情况可以提供解决方案,网络上还没有广泛覆盖 vagrant,我找不到发生这种情况的原因。

【问题讨论】:

  • 看起来你的虚拟机中有一个损坏的文件系统。您是否在 vagrant 机器仍在运行时关闭了您的电脑? GUI 显示的内容是否超过了keys:... 行?
  • @SebastianStigler:我有一个坏习惯,就是不先关闭虚拟机就直接关闭笔记本电脑。以下是三个案例的截图:当我entered Mentered S,然后是another S,如果您需要任何进一步的信息,请告诉我。
  • 你是否得到了一个控制台,或者你在每次点击“S”后要求输入 root 密码?
  • @SebastianStigler:不,输入 M 会再次进入同一个屏幕,输入 S 在keys: _ 中得到stuck
  • 这种情况可能是因为 VirtualBox 未能重定向端口,尽管说 '==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ' 你可以在这里查看我的问题的完整描述link。我仍然不知道如何修复重定向失败(请在我的帖子中添加注释,如果以及如何成功!

标签: linux vagrant virtualbox


【解决方案1】:

在对不同问题的所有可用选项进行了努力之后,我仍然面临同样的问题。 最后,我做了一个

vagrant destroy

紧随其后

vagrant up

我的系统又能正常工作了。

注意:如果你也有直接关机的习惯,你可能很快就会遇到这个问题!在您的 vagrant 终端 (vagrant ssh) 中,始终选择:

sudo shutdown -h now

或者你可以直接输入

vagrant halt

从 ssh 注销后。

PS:对于那些可能害怕在vagrant destroy 期间丢失数据/代码/任何东西的人,你可以放松一下!我对使用该命令犹豫不决,但根据文档,它所做的只是:

此命令停止 Vagrant 正在管理的正在运行的机器并销毁在机器创建过程中创建的所有资源。运行此命令后,您的计算机应该保持干净状态,就好像您从未创建过来宾计算机一样。

这意味着您的代码将保持原样,并且下一个vagrant up 将引导您进入与您离开时相同的状态,只是现在问题已解决。 :)

【讨论】:

  • 退出 ssh 会话后,您只需键入 vagrant halt,而不是 sudo shutdown -h now
  • vagrant destroy 实际上会破坏虚拟机。因此,您会丢失虚拟机中而不是在主机上的所有数据!
  • @SebastianStigler:我已经更新了关于暂停功能的信息。关于数据丢失,我的意思是我写的代码。我正在为 mediawiki 编写扩展程序,但仍然存在,恕我直言,只有虚拟机自己的设置数据被破坏并重新创建。如果我错了,请纠正我。
  • @ankita,我知道这是旧的,但希望它会帮助某人。我不太确定你的代码仍然是什么意思,但你的意见是非常错误的。 vagrant destroy 删除了我的整个虚拟机及其上的所有内容。绝对不是我想要的! Ofc,我先备份了vdkm,现在又从头开始了。
【解决方案2】:

而不是破坏图像。我能够通过首先在 Vagrantfile 中添加以下行/取消注释来打开 virtualbox gui 来解决这个问题。

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

然后我做了 vagrant up 重新启动它。它同时启动了命令行和 virtualbox gui。 Gui 向我询问了 SSH 密码(这是我上次登录机器时使用 ssh 时设置的),然后我就可以登录了。后来我关闭了图像。后来我从 Vagrantfile 中删除了上面的 gui 行,它仍然可以正常启动。

【讨论】:

    猜你喜欢
    • 2014-08-26
    • 2017-10-08
    • 2016-03-24
    • 1970-01-01
    • 1970-01-01
    • 2016-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多