前言 需要在电脑上安装好VirtualBox和Vagrant 构建3台虚拟机 1、编写Vagrantfile文件 内容如下: Vagrant.configure("2") do |config| config.vm.box_check_update = false config.vm.provider 'virtualbox' do |vb| vb.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 1000 ] end $num_instances = 3 # curl https://discovery.etcd.io/new?size=3 (1..$num_instances).each do |i| config.vm.define "node#{i}" do |node| node.vm.box = "centos/7" node.vm.hostname = "node#{i}" ip = "172.17.8.#{i+100}" node.vm.network "private_network", ip: ip node.vm.provider "virtualbox" do |vb| vb.memory = "8192" if i==1 then vb.cpus = 2 else vb.cpus = 1 end vb.name = "node#{i}" end end endend 2、启动3台虚拟机 在Vag...