【问题标题】:random vagrant failures due to Connection timeout errors由于连接超时错误导致的随机流浪失败
【发布时间】:2023-05-15 17:55:02
【问题描述】:

我正在尝试在 VM 中运行 vagrant,但不幸的是它随机失败(它曾经每隔一次都失败)。但是当我将日志级别设置为调试并运行 vagrant up 时,它不会出错。寻求有关如何调试此问题的建议。

主机:rhel 6.5 (Santiago) 2 core 4G ram, ESXi 5.1 来宾机器:rhel 6.5 (Guest Additions Version: 4.1.18)/centOS 6.5 (Guest Additions Version: 4.3.8)

流浪者版本 - 1.6.5 虚拟盒子 4.3.20 Chef 开发套件版本:0.3.6 流浪插件 流浪者-berkshelf (4.0.2) 流浪登录(1.0.1,系统) 流浪汉综合(1.4.1) vagrant-share (1.1.3, 系统)

运行失败

Bringing machine 'default' up with 'virtualbox' provider...
    default: The Berkshelf shelf is at "/root/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150206-18541-kdy12t-default"
==> default: Sharing cookbooks with VM
==> default: Importing base box 'rhel65-1.0.0'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: XXXXXXXXXX_1423257225720_47393
==> default: Clearing any previously set forwarded ports...
==> default: Updating Vagrant's Berkshelf...
==> default: Resolving cookbook dependencies...
==> default: Fetching 'XXXXXXXXXX' from source at .
==> default: Using XXXXXXXXXX (1.2.0) from source at .
==> default: Vendoring XXXXXXXXXX (1.2.0) to /root/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150206-18541-kdy12t-default/XXXXXXXXXX
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2200 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2200
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: 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.

更新: 根据此博客中的说明,我拍摄了我的 VM 的快照:http://www.dedoimedo.com/computers/virtualbox-screenshot.html

我在来宾 VM 中遇到的错误:

MP-BIOS bug: 8254 timer not connected to IO-APIC
kernel panic - not syncing: IO-APIC + timer doesn't work! Boot with apic-debug and send a report. Then try booting with the 'noapic' option.

pid: 1, comm: swapper Tainted: G W -------- 2.6.32-431.el6.x86_64 #1

【问题讨论】:

  • 这可能是我的基础设施设置方式。为了让它始终如一地工作,我把 ioapic: 'off' 关掉了。

标签: vagrant chef-infra vmware vagrantfile cookbook


【解决方案1】:

看看这里Vagrant stuck connection timeout retrying它应该会给你所有你需要的答案。

我首先建议做的是:

  1. 现在将您的 Vagrant 升级到最新版本,它看起来是 1.7.2,而您使用的是 1.6.5。

  2. 将此添加到您的 Vagrantfile 中

    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    
      config.vm.provider "virtualbox" do |vb|
        vb.gui = true
      end
    
    end
    

    它将使 VBox 以 GUI 模式启动您的 Vagrant 构建 VM。 确保它正常启动,并且您可以使用用户名登录它:vagrant 密码:vagrant(这应该是在您的基本框上设置的标准凭据)。

  3. 然后尝试从主机系统通过 SSH 连接到正在运行的 VM。使用相同的 vagrant/vagrant 凭据。

  4. 如果 2 和 3 工作正常,那么您可以尝试将其添加到您的 Vagrantfile: (如果您愿意,也可以将之前为 VBox 指定的 GUI 保留在那里)

    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    
      config.ssh.username = "vagrant"
      config.ssh.password = "vagrant"
    
    end
    

再次流浪你的虚拟机,看看这是否可行。

  1. 如果之前的所有步骤都对您不起作用,我会仔细阅读上面提供的链接中的所有建议。主要是在 BIOS 中启用了 VT-x,Guest VM 上的防火墙关闭设置。

希望这会有所帮助。我现在也是从 Vagrant 开始的,这并不像我想象的那么容易 :) 祝你好运!

【讨论】:

  • 感谢您的帖子。它包含很多有用的信息,但不幸的是没有一个对我有用。
  • 嗨,我知道所有的步骤,包括从主机系统到你的虚拟机的 SSH 都在工作,你仍然得到连接超时错误,对吗??然后我链接的帖子中的任何指南都不起作用??不知道这个基础盒子是从哪里来的,也许它是错误创建的??您能否尝试添加到您的 Vagrant 官方框,看看您是否会让它们工作,即 ubuntu/trusty64 和/或 ubuntu/trusty32。您可以通过发出 'vagrant box add ubuntu/trusty64' 轻松做到这一点,然后尝试基于此基本框创建 VM,看看这是否适合您??
  • 我应该对我之前的评论更详细一点,我很抱歉。我已经尝试了您列出的所有步骤。我无法尝试第 2 步,因为我正在测试的环境已被锁定。即使使用社区盒子,我们也会遇到同样的问题。我试图弄清楚为什么我不能始终如一地打开盒子。每成功运行 10 到 15 次后,我就会收到一个连接超时错误。我们甚至安装了 zabbix,以查看当 vagrant 错误出现时是否在主机 VM 中耗尽内存。当它们出错时,它们平均有大约 1.7 G 的可用内存。
  • 抱歉回复晚了。这对我来说似乎是一个网络问题。虽然您在创建自己的基本盒子时可能会犯一些错误,但我很确定它们已正确设置。不确定您在编写时正在使用的环境是“锁定”的。也许有一些规则阻止您连接到这些虚拟机?只是一个想法。抱歉,我帮不上什么忙。
【解决方案2】:

在尝试了不同门户上可用的各种选项后,最后我做了一个vagrant destroy 其次是vagrant up,它对我有用...... :)

【讨论】: