2、修改配置文件如下:
# -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("2") do |config| config.vm.provision "shell", inline: "echo Hello" config.vm.define "master" do |saltmaster| saltmaster.vm.box = "base" saltmaster.vm.host_name = 'saltmaster.local' saltmaster.vm.network "private_network", ip: "192.168.33.13" saltmaster.ssh.username = 'root' saltmaster.ssh.password = 'vagrant' saltmaster.ssh.insert_key = 'true' end config.vm.define "minion" do |saltminion| saltminion.vm.box = "base" saltminion.vm.host_name = 'saltminion.local' saltminion.vm.network "private_network", ip: "192.168.33.14" saltminion.ssh.username = 'root' saltminion.ssh.password = 'vagrant' saltminion.ssh.insert_key = 'true' end end3、正常启动即可 : vagrant up
4、登录
使用 vagrant ssh + 名称 登录
pylixm@pylixm-pc /d/vagrant/dev331314 $ vagrant ssh master root@127.0.0.1's password: Welcome to your Vagrant-built virtual machine. [root@saltmaster ~]#
使用 ip 直接登录
将已有 virtualbox 虚机添加到 vagrant管理直接添加是不行的,这里提供了一中变向的方式:先将virtualbox 的虚机转成 box 镜像 ,再将镜像添加到 vagrant 管理;
详细 –> 这里
1、打包已有虚机(虚机必须用virtualbox打开过,为了让virtualbox可以找到该虚机)
vagrant package --base mybox --output /path/to/mybox.box2、添加 box 镜像
vagrant box add mybox /path/to/mybox.box如何使用vagrant在虚拟机安装Hadoop集群