Vagrant 多机并行启动 [英] Vagrant Multi-Machine Parallel Start

查看:39
本文介绍了Vagrant 多机并行启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置一个主-主 MySQL 对,并且只有当它们都启动时才能正确配置它们.

I'm trying to provision a master-master MySQL pair and they can only be configured correctly if both of them are up.

Vagrant.configure("2") do |config|
  web.vm.box = "centos/7"

  config.vm.define "primary" do |primary|
    .......
  end

  config.vm.define "secondary" do |secondary|
    .......
  end
end

我已经运行过多次,Vagrant 仅在第一个虚拟机启动后才启动第二个虚拟机.

I've run thru this multiple times and Vagrant only starts the second vm after the first one is up.

有没有办法强制 Vagrant 同时启动两个虚拟机?

Is there any way to force Vagrant to start up two VM's at the same time?

推荐答案

vagrant up 支持并行VM启动键--parallel:

vagrant up supports parallel VM start with the key --parallel:

--[no-]parallel 如果提供者支持,则启用或禁用并行性

--[no-]parallel Enable or disable parallelism if provider supports it

默认 vagrant provider VirtualBox 不支持它,但你可以使用 xargs 同时启动你的虚拟机,它支持并行命令执行键 -P (为您的 Vagrantfile 提供的示例):

Default vagrant provider VirtualBox doesn't support it, but you can start your VMs simultaneously using xargs, which supports parallel command execution with the key -P <max-procs> (example provided exactly for your Vagrantfile):

grep config.vm.define Vagrantfile | awk -F'"' '{print $2}' | xargs -P2 -I {} vagrant up {}

这篇关于Vagrant 多机并行启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆