2016-08-01 195 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從來沒有爲我工作過。 –