首页 > 代码库 > vagrant 之使用
vagrant 之使用
1. 安装
安装VirtualBox
安装Vagrant
2.BOX
下载 http://www.vagrantbox.es/
https://atlas.hashicorp.com/ubuntu/boxes/xenial64
3.2
两种方式 BOX安装
在线
vagrant init ubuntu/xenial64 生成vagrantfile文件
vagrant up
离线
vagrant box add 名称 本地路径
vagrant init
vagrant up
4.配置
虚拟机配置为
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.define :web do |web_config|
config.vm.hostname = "web"
config.vm.network "public_network", ip: "192.168.1.51"
config.vm.synced_folder "f:/vmdata/web", "/vagrant_data"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = 1
vb.name="web"
end
end
config.vm.define :redis do |redis_config|
config.vm.hostname = "redis"
config.vm.network "public_network", ip: "192.168.1.52"
config.vm.synced_folder "../data/redis", "/vagrant_data"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = 1
vb.name="redis"
end
end
config.vm.define :mysql1 do |mysql1_config|
config.vm.hostname = "mysql1"
config.vm.network "public_network", ip: "192.168.1.53"
config.vm.synced_folder "../data/mysql1", "/vagrant_data"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = 1
vb.name="mysql1"
end
end
config.vm.define :mysql2 do |mysql2_config|
config.vm.hostname = "mysql2"
config.vm.network "public_network", ip: "192.168.1.54"
config.vm.synced_folder "../data/mysql2", "/vagrant_data"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = 1
vb.name="mysql2"
end
end
end
4.4
vagrant 之使用