Vagrant Connection超时错误

时间:2015-08-09 11:14:27

标签: vagrant

我正在尝试按照书中的说明进行操作,其中涉及根据我从Vagrantfile下载的git clone https://github.com/jorhett/learning-puppet4来调出一个流浪的实例。为方便起见,以下是Vagrantfile

的内容
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.5.2"

# Copy files into place
$setupscript = <<END
  # Hardlock domain name
  echo 'supercede domain-name "example.com";' > /etc/dhcp/dhclient.conf

  # Install etc/hosts for convenience
  cp /vagrant/etc-puppet/hosts /etc/hosts

  # Install puppet.conf in user directory to quiet deprecation warnings
  #mkdir -p /home/vagrant/.puppetlabs/etc/puppet
  #cp /vagrant/etc-puppet/puppet.conf /home/vagrant/.puppetlabs/etc/puppet
  #chown -R vagrant:vagrant /home/vagrant/.puppetlabs

  # Install example hiera settings in global directory
  mkdir -p /etc/puppetlabs/puppet
  cp -r /vagrant/etc-puppet/* /etc/puppetlabs/puppet/
  mkdir -p /etc/puppetlabs/code
  chown -R vagrant:vagrant /etc/puppetlabs

  # Provide the URL to the Puppet Labs yum repo on login
  echo "
You should start by enabling the Puppet Labs Puppet Collection 1 release repo
   sudo yum install http://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm

Then install Puppet 4 and its companion packages
   sudo yum install -y puppet-agent

" > /etc/motd
  # Enable MotD
  sed -i -e 's/^PrintMotd no/PrintMotd yes/' /etc/ssh/sshd_config
  systemctl reload sshd
END

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "puppetlabs/centos-7.0-64-nocm"
  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]
  end

  # Default client
  config.vm.define "client", primary: true do |client|
    client.vm.hostname = "client.example.com"
    client.vm.network :private_network, ip: "192.168.250.10"
    client.vm.provision "shell", inline: $setupscript
  end

  # A puppetmaster
  config.vm.define "puppetmaster", autostart: false do |puppetmaster|
    puppetmaster.vm.hostname = "puppetmaster.example.com"
    puppetmaster.vm.network :private_network, ip: "192.168.250.5"
    puppetmaster.vm.provision "shell", inline: $setupscript
  end

  # Puppet Server
  config.vm.define "puppetserver", autostart: false do |puppetserver|
    puppetserver.vm.hostname = "puppet-server.example.com"
    puppetserver.vm.network :private_network, ip: "192.168.250.6"
    puppetserver.vm.provision "shell", inline: $setupscript
    puppetserver.vm.provider :virtualbox do |ps|
      ps.memory = 1024
    end
  end
end

运行vagrant up client时,我收到以下错误结束的输出:

Bringing machine 'client' up with 'virtualbox' provider...
==> client: Importing base box 'puppetlabs/centos-7.0-64-nocm'...
==> client: Matching MAC address for NAT networking...
==> client: Checking if box 'puppetlabs/centos-7.0-64-nocm' is up to date...
==> client: Setting the name of the VM: learning-puppet4_client_1439117612834_66
905
==> client: Clearing any previously set network interfaces...
==> client: Preparing network interfaces based on configuration...
    client: Adapter 1: nat
    client: Adapter 2: hostonly
==> client: Forwarding ports...
    client: 22 => 2222 (adapter 1)
==> client: Running 'pre-boot' VM customizations...
==> client: Booting VM...
==> client: Waiting for machine to boot. This may take a few minutes...
    client: SSH address: 127.0.0.1:2222
    client: SSH username: vagrant
    client: SSH auth method: private key
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: Warning: Connection timeout. Retrying...
    client: 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.

如何解决并修复此错误?

1 个答案:

答案 0 :(得分:0)

这种情况发生在一个非常低的水平 - Vagrant实例的启动距离远远不足以进行配置,所以你从Vagrant文​​件引用的内容都不相关。

查找计算机上Vagrant设置的问题,并检查计算机的日志文件。特别是,检查内存不足的情况。

您可以尝试将Vagrant文​​件简化为非常简单的操作,无需任何配置工作,并在虚拟机启动之前使用它。

VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.5.2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "puppetlabs/centos-7.0-64-nocm"
  # Default client
  config.vm.define "client", primary: true do |client|
    client.vm.hostname = "client.example.com"
    client.vm.network :private_network, ip: "192.168.250.10"
  end
end