【问题标题】:Vagrant up stuck流浪者卡住了
【发布时间】:2016-12-06 17:17:39
【问题描述】:

我正在运行vagrant up,我面临一个问题,它似乎一开始就是这个Vagrant stuck connection timeout retrying。我已经尝试了那里的所有解决方案,我也做了vagrant destroy,但是一旦我做vagrant suspend,那么vagrant up 命令不起作用,我必须退出并做vagrant reload 才能得到虚拟机工作。这很烦人和令人沮丧。

我目前正在使用 vagrant homestead 0.4.4 版,这个问题的一部分在 VM 启动后一切正常。

我当前的系统是 OSX El Captain。

如果您需要更多详细信息,请告诉我。

我的Vagrantfile

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path("vendor/laravel/homestead", File.dirname(__FILE__))

homesteadYamlPath = "Homestead.yaml"
homesteadJsonPath = "Homestead.json"
afterScriptPath = "after.sh"
aliasesPath = "aliases"

require File.expand_path(confDir + '/scripts/homestead.rb')

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    if File.exists? homesteadYamlPath then
        Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
    elsif File.exists? homesteadJsonPath then
        Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
    end

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end
end

错误时命令up output

~/Projects/credentialsApi (feature/10)$vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: A newer version of the box 'laravel/homestead' is available! You currently
==> default: have version '0.4.4'. The latest is version '0.5.0'. Run
==> default: `vagrant box update` to update.
==> default: Resuming suspended VM...
==> 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: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. 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.
~/Projects/credentialsApi (feature/10)$

vagrant ssh-config 命令输出:

~/Projects/credentialsApi (development)$vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2204
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile "/Users/pabloleone/Projects/credentialsApi/.vagrant/machines/default/virtualbox/private_key"
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardAgent yes

【问题讨论】:

  • 你能粘贴你的命令、Vagrantfile 内容和输出吗?还要为您的命令添加前缀VAGRANT_LOG=debug 并粘贴相关部分。
  • 我运行了这个命令 vagrant up --debug 并且输出很大,我认为没有用。
  • 您能粘贴连接超时错误吗?在“启动虚拟机”和错误本身之间?您已经从其他答案中尝试过什么,结果如何?
  • vagrant reload 之后是vagrant ssh 工作正常吗?
  • 我都试过了,是的,出现错误后,vagrant reload 工作正常。

标签: laravel vagrant homestead


【解决方案1】:

我终于解决了这个问题。这是由于版本。我刚刚升级了 vagrant 和虚拟机。

【讨论】:

    【解决方案2】:

    首先,尝试使用VAGRANT_LOG=debug 变量运行vagrant 来调试问题。


    如果这不起作用,当它显示超时消息时,在另一个终端运行:vagrant status 以查看 VM 是否正常运行。或者直接从 GUI 运行 VirtualBox 并检查机器状态。


    如果它正在运行,请通过以下命令检查 SSH 凭据是否正确:

    vagrant ssh-config
    

    为了:

    • 检查主机名和端口(例如127.0.0.1:2222),
    • 您的私钥 (IdentityFile)。

    也可以尝试通过以下方式手动登录虚拟机:

    vagrant ssh
    

    或通过this command(将default从上面的ssh-config命令更改为正确的主机):

    vagrant ssh-config > vagrant-ssh && ssh -F vagrant-ssh default
    

    由于它在 vagrant reload 之后对您有效(因此您的 BIOS 中的虚拟化支持可能已启用),可能由于某些问题,您的 SSH 服务器在恢复时默认未启动。然后,您应该通过vagrant reload && vagrant ssh 修复它来检查 SSH 日志,并通过以下方式检查日志:

    sudo tail /var/log/secure
    

    如果是这种情况,要检查 SSH 服务是否运行,请添加以下行,如:

    config.vm.provision :shell, run: "always", path: "scripts/check_ssh_service.sh"
    

    类似问题:Apache doesn't start after Vagrant reload


    最后查看以下列表,了解 SSH 超时问题的可能解决方案:

    • 确保您的防火墙或防病毒软件没有阻止程序(我怀疑这种情况会经常发生)
    • 给你的流浪机器一些时间让超时发生。如果您没有速度非常快的 PC/Mac,VM 将需要一段时间才能启动到 SSH 就绪状态,因此会发生超时。
    • 因此,在断定有故障之前,首先尝试让 vagrant 完全超时。
    • 如果 vagrant 完全超时,则将 vagrant 文件中的超时限制增加到几分钟,然后重试。
    • 如果还是不行,请尝试通过 VirtualBox 界面干净启动您的 vagrant 机器并启用 GUI 机前。如果 GUI 没有显示任何发生的事情(即。 只是黑屏,没有文字),而它正在启动,然后你的流浪汉 机器出现问题。
    • 通过VB界面销毁整机并重新安装。
    • 删除用户文件夹中Vagrant Images文件夹中的ubuntu镜像文件,重新下载安装。
    • 您是否有支持 64 位硬件虚拟化的英特尔处理器?去谷歌上查询。如果你这样做,请确保没有设置 您的 Bios 禁用了此功能。
    • 如果您运行的是 Windows 7 或 8,请禁用 hyper-v 功能。Google 如何禁用。
    • 确保您通过启用 SSH 的客户端运行。使用 Git bash。下载:http://git-scm.com/downloads
    • 安装 32 位版本的 ubuntu,例如 trusty32 或precision32。只需更改 vagrant 文件中的版本并在 new 中重新安装 vagrant 目录。
    • 确保您使用的是最新的 vagrant 和 virtualbox 版本。
    • 最后的手段:格式化您的计算机,重新安装 Windows 并购买一个 intel core isothing 处理器。

    来源:@dezinerdudes 的 GitHub 帖子


    另见:SSH Timeout - Cant connect via ssh no matter what

    【讨论】:

    • 感谢您的大力响应。我用vagrant ssh-config 命令输出更新了这个问题。我检查了 SSH 日志,什么也没有,然后我用调试密钥运行虚拟机,哇!输出量大,用处不大。错误期间的流浪状态表示 VM 正在运行。另一个帮助是针对 Ubuntu 的,我在 Mac 上。我确实尝试了其中一些,但问题仍然存在。
    • @PabloEzequielLeone 端口不匹配:2222 != 2204,您应该调查错误端口的来源。您是否覆盖了 ~/.ssh/config 中与 vagrant 相关的任何内容?
    • 我确实更改了端口以使它们匹配,但问题仍然存在。我还使用凭据设置了登录,但没有运气。我正在调查 Docker,Vagrant 从来没有为我正常工作过!
    猜你喜欢
    • 1970-01-01
    • 2022-01-26
    • 2014-07-04
    • 2015-02-17
    • 1970-01-01
    • 1970-01-01
    • 2019-02-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多