5运行多个vagrant主机
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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主机的主要内容,如果未能解决你的问题,请参考以下文章
当主机更改源时,grunt karma 对 vagrant 进行测试 grunt/karma 未检测到它
获取在 Vagrant VM 上运行的 LAMP 堆栈(在 Windows 7 主机下),完整说明?
如何在Visual Studio代码中配置PHP可执行文件,其中我的设置 是Windows 10主机中的Vagrant Ubuntu 16.06