vmware下载地址:https://www.vmware.com/products/workstation-pro/workstation-pro-evaluation.html
VirtualBox下载地址:https://www.virtualbox.org/wiki/Downloads
Vagrant下载地址:https://developer.hashicorp.com/vagrant/install#Windows
Vagrant镜像下载地址:https://app.vagrantup.com/boxes/search
新建一个文件夹
D:\vagrant\centos7
生成centos/7 Vagrantfile
vagrant init centos/7
创建并启动虚拟机
vagrant up
连接虚拟机
vagrant ssh
重启虚拟机
vagrant reload
Vagrantfile
virtual box
Vagrant.configure("2") do |config|# 使用CentOS 7的官方Vagrant boxconfig.vm.box = "centos/7"# 设置固定ipconfig.vm.network "private_network", type: "static", ip: "192.168.33.10"# 设置虚拟机内部的主机名config.vm.hostname = "centos7-vm"config.vm.provider "virtualbox" do |vb|vb.gui = true# 设置VirtualBox界面上显示的虚拟机名称vb.name = "centos7-vm"vb.memory = "1024"vb.cpus = 2endend
VMware
使用管理员身份打开命令提示符,安装插件
vagrant plugin install vagrant-vmware-desktop
Vagrant.configure("2") do |config|# 使用CentOS 7的官方Vagrant boxconfig.vm.box = "centos/7"# 设置固定ipconfig.vm.network "private_network", type: "static", ip: "192.168.33.10"# 设置虚拟机内部的主机名config.vm.hostname = "centos7-vm"# 使用VMware提供者config.vm.provider "vmware_desktop" do |vmware|# 设置VirtualBox界面上显示的虚拟机名称vmware.name = "centos7-vm"# 配置内存和CPUvmware.memory = "1024"vmware.cpus = 2endend