Note: The preferred network connection mode for multiple virtual machine launches is Host-only networking
1. One of the simplest configurations
Vagrant.configure (2) Do |config| Config.vm.box = "CentOS" Config.vm.box_url = "G:/vagrant-centos-6.7.box" config.ssh.username = "vagrant" Config.ssh.pas Sword = "vagrant" config.vm.define "web" do |web| Web.vm.network "Private_network", IP: "192.168.33.10" End Config.vm.define "db" Do |db| Db.vm.network "Private_network", IP: "192.168.33.11" EndEnd
2. Specific configuration for each virtual machine
Vagrant.configure (2) do |config| config.vm.define "Web" do |web| web.vm.box = "CentOS" web.vm.box_url = "C:/me/vagrant-centos-6.7.box" web.vm.hostname = "CentOS" web.vm.network "Private_network", ip: "192.168.56.10" web.vm.provider "VirtualBox" do |v| v.gui = false v.name = "CentOS" v.cpus = "1" v.memory = " 2048 "end end config.vm.define " DB " do |db| db.vm.box = "Ubuntu" db.vm.box_url = "c:/me/ Ubuntu-14.04-amd64.box "db.vm.hostname = " Ubuntu " db.vm.network " Private_ Network ", ip: " 192.168.56.11 "db.vm.provider " VirtualBox " do |v| v.gui = false v.name = "UBuntu-1 " v.cpus = " 1 " v.memory = " 2048 "end endend
3. Multi-Machine management
3.1 Viewing status
The Vagrant status==> output is as follows current machine States:web running (VirtualBox) DB run Ning (VirtualBox) This environment represents multiple VMs. The VMs is all listedabove with their current state. For more information about a SPECIFICVM, run ' vagrant status NAME '.
3.2 Reload Configuration
Vagrant Reload Web db
This article is from "Mr. Peach" blog, please be sure to keep this source http://peach3412.blog.51cto.com/12037226/1850723
5. Running multiple vagrant hosts