欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

vagrant安装多台虚拟机

程序员文章站 2022-06-24 23:54:25
...

在vagrant目录下新建配置文件Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

servers = {
    :centos71 => '192.168.33.10',
    :centos72 => '192.168.33.11',
    :centos73 => '192.168.33.12'
}

Vagrant.configure("2") do |config|
  config.vm.box = "puppetlabs/centos-7.2-64-nocm"
  config.vm.box_check_update = false

  servers.each do |server_name, server_ip|
      config.vm.define server_name do |server_config|
          server_config.vm.hostname = "#{server_name.to_s}"
          server_config.vm.network :private_network, ip: server_ip
          server_config.vm.provider "virtualbox" do |vb|
              vb.name = server_name.to_s
                        vb.memory = "1024"
                        vb.cpus = 1
         end
      end
  end
end

添加虚拟机

vagrant box add --name centos7 centos-7.0-x86_64.box

vagrant安装多台虚拟机

启动vagrant up

vagrant安装多台虚拟机

vagrant安装多台虚拟机

vagrant安装多台虚拟机

vagrant安装多台虚拟机

可以看到三台全部启动成功

用户root 密码vagrant