虚拟机上的Vagrant慢SSH(Ubuntu可靠主机和客户端)

时间:2017-02-27 15:13:58

标签: ubuntu ssh vagrant virtualbox

我在设置与Virtualbox提供商的Vagrant SSH连接时遇到问题。我对Ruby和Vagrant都很陌生。我想知道是否有人可以帮助我并指出如何解决这个问题的正确方向。

我附上了我认为可能有用的所有可能信息。

root@node1:~/VagrantStuff/vbVagrantSimple# vagrant up
Bringing machine '01-firstVBServer' up with 'virtualbox' provider...
==> 01-firstVBServer: Importing base box 'ubuntu/trusty64'...
==> 01-firstVBServer: Matching MAC address for NAT networking...
==> 01-firstVBServer: Checking if box 'ubuntu/trusty64' is up to date...
==> 01-firstVBServer: Setting the name of the VM: vbVagrantSimple_01-   firstVBServer_1488206801438_77523
==> 01-firstVBServer: Clearing any previously set forwarded ports...
==> 01-firstVBServer: Fixed port collision for 22 => 2222. Now on port 2200.
==> 01-firstVBServer: Clearing any previously set network interfaces...
==> 01-firstVBServer: Preparing network interfaces based on configuration...
01-firstVBServer: Adapter 1: nat
01-firstVBServer: Adapter 2: hostonly
01-firstVBServer: Adapter 3: bridged
==> 01-firstVBServer: Forwarding ports...
01-firstVBServer: 22 => 2200 (adapter 1)
==> 01-firstVBServer: Running 'pre-boot' VM customizations...
==> 01-firstVBServer: Booting VM...
==> 01-firstVBServer: Waiting for machine to boot. This may take a few minutes...
01-firstVBServer: SSH address: 127.0.0.1:2200
01-firstVBServer: SSH username: vagrant
01-firstVBServer: SSH auth method: private key
01-firstVBServer: Warning: Connection timeout. Retrying...
01-firstVBServer: Warning: Remote connection disconnect. Retrying...
01-firstVBServer: Warning: Connection timeout. Retrying...
01-firstVBServer: Warning: Connection timeout. Retrying...
01-firstVBServer: Warning: Connection timeout. Retrying...
01-firstVBServer: Warning: Connection timeout. Retrying...
01-firstVBServer: Warning: Connection timeout. Retrying...
01-firstVBServer: Warning: Connection timeout. Retrying...
==> 01-firstVBServer: Machine booted and ready!
==> 01-firstVBServer: Checking for guest additions in VM...
==> 01-firstVBServer: Setting hostname...
==> 01-firstVBServer: Configuring and enabling network interfaces...

“流浪汉”的总时间:8分钟++(我在这里停止了计时器,已经因为花了多长时间而烦恼)。 是时候进入SSH尝试了:45秒(OK时间)。 是时候通过重试来实际SSH:2分05秒(NOK) 配置和启用网络接口的时间:5分钟++(NOK)。

Vagrant.configure(2) do |config|

 vagrant_version = Vagrant::VERSION.sub(/^v/, '')

 config.vm.provider :virtualbox do |v|
     v.customize ["modifyvm", :id, "--memory", 1024]
     v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
     v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
     v.customize ["modifyvm", :id, "--nictype1", "virtio"]
 end

 config.vm.boot_timeout = 600
 config.ssh.forward_agent = true
 config.ssh.insert_key = false
 config.vm.network :private_network, ip: "192.168.50.4"


 ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'


 config.vm.define "01-firstVBServer", primary: true do |firstVBServer|

   firstVBServer.vm.box = "ubuntu/trusty64"
   firstVBServer.vm.hostname = "01-firstServer-VB"
   firstVBServer.vm.network "public_network" , bridge: "eth0"
   firstVBServer.vm.synced_folder ".", "/vagrant", :nfs => { :mount_options => ["dmode=777","fmode=777"] }

   firstVBServer.vm.provider :virtualbox do |vb|
       vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
   end

   firstVBServer.vm.provision :shell, inline: "
    sudo echo \"Acquire::http::Proxy \\\"http://31.250.0.80:8118\\\";\" >> /etc/apt/apt.conf
    sudo apt-get -y update
    sudo apt-get -y upgrade"
 end

end

我也在DEBUG模式下运行流浪汉,我认为这不是真的有用,但如果有人认真对待它,那么这是21000行输出:

vagrant up 

在DEBUG模式下:

http://s000.tinyupload.com/?file_id=11702713612886687285

我很感谢任何帮助我的尝试。

0 个答案:

没有答案