2016-08-01 196 views
3

我正在运行vagrant up,我正面临一个问题,它似乎是开头Vagrant stuck connection timeout retrying。我已经尝试了所有的解决方案,我也做了vagrant destroy,但只要我做了vagrant suspend,那么vagrant up命令不起作用,我必须退出并执行vagrant reload才能让VM工作。这非常烦人和令人沮丧。流氓卡住了

我现在使用的是vagrant homestead版本0.4.4,而且这个问题的一部分一旦虚拟机启动就完美运行。

我现在的系统是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 
+0

你可以粘贴你的命令,Vagrantfile内容和输出吗?在'VAGRANT_LOG = debug'前加上你的命令并粘贴相关部分。 – kenorb

+0

我跑这个命令vagrant up - 调试和输出是巨大的我不认为是有用的。 –

+0

您能否粘贴连接超时错误?在'启动虚拟机'和它自己的错误之间?您从其他答案中已经尝试过了什么,结果如何? – kenorb

回答

0

我终于解决了该问题。这是由于版本。我只是升级了流浪汉和虚拟机。

0

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


如果这不会帮助,但它显示超时消息,在另一个终端运行您:vagrant status看VM是否正确或不运行。或者直接从GUI运行VirtualBox并检查机器状态。


如果它的运行,检查SSH信用凭证是否正确,用下面的命令:

vagrant ssh-config 

为:

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

还尝试通过手动登录到VM:

vagrant ssh 

或通过this command(从上面的ssh-config命令适当的主机改变default):

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

因为它适用于vagrant reload(so您的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超时问题可能的解决方案如下列表:

  • Make sure your firewall or antivirus is not blocking the program (which I doubt will happen often)
  • Give your vagrant machine some time for timeouts to happen. If you dont have a very fast PC/Mac, the VM will take while to boot into an SSH ready state, so timeouts will happen.
  • Therefore, first try to let vagrant timeout COMPLETELY before concluding that there is a fault.
  • If vagrant times out completely then increase the timeout limit in the vagrant file to a few min and try again.
  • If that still doesnt work, then try to clean boot your vagrant machine through the VirtualBox interface and enable the GUI of the machine beforehand. If the GUI doesn't show anything happening (ie. just blackscreen, no text) while it is booting, then your vagrant machine has got problems.
  • Destroy the entire machine through the VB interface and reinstall.
  • Delete the ubuntu image files in the Vagrant Images folder in the user folder and redownload and install.
  • Do you even have an intel processor that supports 64bit hardware virtualisation? Google it. If you do, make sure there is no setting in your Bios disabling this feature.
  • Disable hyper-v feature if you are running windows 7 or 8. Google how to disable.
  • Make sure you are running through an SSH enabled client. Use Git bash. Download: http://git-scm.com/downloads
  • Install a 32bit version of ubuntu like trusty32 or precise32. Just change the version in the vagrant file and reinstall vagrant in new directory.
  • Make sure you are using the latest vagrant and virtualbox versions.
  • Last resorts: Format your computer, reinstall windows and buy an intel core isomething processor.

来源:GitHub上后通过@dezinerdudes


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

+0

谢谢你的回应。我用'vagrant ssh-config'命令输出更新了这个问题。我检查了SSH日志,没有,然后我用调试密钥运行虚拟机,哇!产量巨大,不是很有用。错误期间的流浪状态表示虚拟机正在运行。其他的帮助是Ubuntu,我在Mac上。我确实尝试了其中的一些,但仍然是问题。 –

+0

@PabloEzequielLeone端口不匹配:2222!= 2204,您应该调查错误端口的来源。你是否在'〜/ .ssh/config'中重写了与流浪汉有关的任何东西? – kenorb

+0

我确实改变了端口以使它们匹配,但仍然是问题。我也用凭证设置了登录,但没有运气。我正在调查Docker,Vagrant从来没有为我工作过。 –