标签:虚拟化、自动化
注释:多虚拟机启动的首选网络连接方式是host-only networking
1. 一个最简单的配置
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.password = "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" end end
2. 针对每个虚拟机进行具体的配置
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 end end
3. 多机管理
3.1 查看状态
vagrant status ==>输出如下 Current machine states: web running (virtualbox) db running (virtualbox) This environment represents multiple VMs. The VMs are all listed above with their current state. For more information about a specific VM, run `vagrant status NAME`.
3.2 重新载入配置
vagrant reload web db
本文出自 “桃子先生” 博客,请务必保留此出处http://peach3412.blog.51cto.com/12037226/1850723
标签:虚拟化、自动化
原文地址:http://peach3412.blog.51cto.com/12037226/1850723