我使用多机设置并启动5台机器,当我输入 vagrant up
当我被问及输入时,我希望输入是一个默认值1(我不想一直打5次1)。
这是流浪者档案
IMAGE_NAME = "ubuntu/bionic64"
N = 2
Vagrant.configure("2") do |config|
config.vm.box_check_update = false
# Master Nodes
(1..N).each do |i|
config.vm.define "master-#{i}" do |master|
master.vm.box = IMAGE_NAME
master.vm.hostname = "master-#{i}"
master.vm.network "public_network", ip: "192.168.5.#{i + 10}"
master.vm.network "private_network", ip: "192.168.11.#{i + 10}"
end
end
# Worker Nodes
(1..N).each do |i|
config.vm.define "node-#{i}" do |node|
node.vm.box = IMAGE_NAME
node.vm.hostname = "node-#{i}"
node.vm.network "public_network", ip: "192.168.6.#{i + 10}"
node.vm.network "private_network", ip: "192.168.12.#{i + 10}"
end
end
# Load Balancer
config.vm.define "load-balancer" do |lb|
lb.vm.box = IMAGE_NAME
lb.vm.hostname = "load-balancer"
lb.vm.network "public_network", ip: "192.168.7.11"
lb.vm.network "private_network", ip: "192.168.13.11"
end
end
在你的Vagrant文件中,你应该在你使用的任何地方添加以下内容 public_network
你需要指定网络适配器
<machine>.vm.network "public_network", ip: xxx, bridge: "nat"