首页 > 代码库 > 5、运行多个vagrant主机
5、运行多个vagrant主机
注释:多虚拟机启动的首选网络连接方式是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
5、运行多个vagrant主机
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。