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 box
config.vm.box = "centos/7"
# 设置固定ip
config.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 = 2
end
end
VMware
Vagrant VMware Utility下载地址:https://developer.hashicorp.com/vagrant/install/vmware
使用管理员身份打开命令提示符,安装插件
vagrant plugin install vagrant-vmware-desktop
Vagrant.configure("2") do |config|
# 使用CentOS 7的官方Vagrant box
config.vm.box = "centos/7"
# 设置固定ip
config.vm.network "private_network", type: "static", ip: "192.168.33.10"
# 设置虚拟机内部的主机名
config.vm.hostname = "centos7-vm"
# 使用VMware提供者
config.vm.provider "vmware_desktop" do |vmware|
# 配置内存和CPU
vmware.memory = "1024"
vmware.cpus = 2
end
end
账号密码
账号:
普通用户:vagrant
管理员:root
密码:vagrant
Xshell/FinalShell连接虚拟机
su root
vim /etc/ssh/sshd_config
PasswordAuthentication yes
PermitRootLogin yes
systemctl restart sshd