...
Note: these steps have been tested on MacOS 10.11.6.
Terminology
...
A virtual machine, or VM, is a software program that exhibits the behavior of a separate computer and is capable of running applications and programs within its own environment.
...
Change your current directory to
ambari-vagrant
:Code Block cd ambari-vagrant
If you run an
ls
command on theambari-vagrant
directory, you will see subdirectories for several different operating systems and operating system versions.cd
into the OS subdirectory for the OS you wish to use. CentOS is recommended, because it is quicker to launch than other operating systems.
The remainder of this example uses CentOS 7.0 . (To install and use a different version or distribution of Linux, specify the other directory name in place ofcentos7.0
.)Code Block cd centos7.0
Important: All VM
vagrant
commands operate within your current directory. Be sure to run them from the local (Mac) subdirectory associated with the VM operating system that you have chosen to use. If you attempt to run avagrant
command from another directory, it will not find the VM.Copy the private key into the directory associated with the chosen operating system.
For this example, which usescentos7.0
, issue the following command:Code Block cp ~/.vagrant.d/insecure_private_key .
(Optional) If you have at least 16 GB of memory on your Mac, consider increasing the amount of memory allocated to the VMs.
Edit the following line inVagrantfile
, increasing allocated memory from 3072 to 4096 or more; for example:Code Block vb.customize ["modifyvm", :id, "--memory", 4096] # RAM allocated to each VM
- Every virtual machine will have a directory called
/vagrant
inside the VM. This corresponds to theambari-vagrant/<os>
directory on your local computer, making it easy to transfer files back and forth between your host Mac and the virtual machine. If you have any files to access from within the VM, you can place them in this shared directory. Start one or more VMs, using the
./up.sh
command. Each VM will run one HDP node. Recommendation: if you have at least 16GB of RAM on your Mac and wish to run a small cluster, start with three nodes.Code Block ./up.sh <# of VMs to launch>
Additional notes:
- The defaultVagrantfile
(in each OS subdirectory) can create up to 10 virtual machines.
- The fully-qualified domain name (FQDN) for each VM has the format<os-code>[01-10].ambari.apache.org
, where<os-code>
isc59
(CentOS 5.9),c64
(CentOS 6.4), etc. For example,c5901.ambari.apache.org
will be the FQDN for node 01 running CentOS 5.9.
- The IP address for each VM has the format192.168.<os-subnet>.1[01-10]
, where<os-subnet>
is64
for CentOS 6.4,70
for CentOS 7.0, and so on. For example,192.168.70.101
will be the IP address for CentOS 7.0 nodec7001
.
For example, the following command starts 3 VMs:./up.sh 3
For CentOS 7.0, the associated hostnames will bec7001
,c7002
, andc7003
. Note that theup.sh 3
command is equivalent tovagrant up c700{1..3}
.Check the status of your VM(s). The following example shows the results of
./upsh 3
for three VMs running with CentOS 7.0:Code Block LMBP:centos6.4 lkg$ vagrant status Current machine states: c7001 running (virtualbox) c7002 running (virtualbox) c7003 running (virtualbox) c7004 not created (virtualbox) c7005 not created (virtualbox) c7006 not created (virtualbox) c7007 not created (virtualbox) c7008 not created (virtualbox) c7009 not created (virtualbox) c7010 not created (virtualbox)
Your virtual machines are now installed and running.
...
Access Virtual Machines
Use the following steps when you want to access a running virtual machine:
...
A Vagrant snapshot saves the current state of a VM so that you can restart the VM from the same point at a future time. Vagrant makes it easy to take snapshots of the entire cluster. First, install
Install the snapshot plugin:
Code Block vagrant plugin install vagrant-vbox-snapshot --plugin-version=0.0.2
This enables the “vagrant snapshot” command. Note that the above installs version 0.0.2, which allows you to take snapshots of the whole cluster at the same time. Later versions do not support this feature.
Run
vagrant snapshot
to see the syntax. Runvagrant snapshot <command> -h
for more information about a specific command. Here is a summary of commands:
vagrant snapshot back # restore most recent snapshot
vagrant snapshot delete <SNAPSHOT_NAME> # delete specified snapshot
vagrant snapshot go [vm-name] <SNAPSHOT_NAME> # restore specified snapshotvagrant snapshot list # list snapshots
vagrant snapshot take [vm-name] <SNAPSHOT_NAME> # take a snapshot, labeled by SNAPSHOT_NAME
The plugin attempts to take a snapshot of all VMs configured in Vagrantfile
. To avoid attempts to snapshot nonexistent VMs, comment out the nonexistent VMs in Vagrantfile
. For example, if you have three VMs running you can comment out c70 Note that the plugin tries to take a snapshot of all VMs configured in Vagrantfile. If you are always using 3 VMs, for example, you can comment out c64[04-10] in Vagrantfile
so that the snapshot commands only operate on c64c70[01-03].
Note: Upon resuming a snapshot, you may find that time-sensitive services may be down (e.g, HBase RegionServer is down, etc.). If this happens, you will need to restart those services.
Recommendation: After you start the VMs--Tip: After starting the VMs but before you do run anything on the VMs, --run "vagrant snapshot take init
". This way, you can go back to the initial state of the VMs by running "vagrant snapshot go init"; this only takes seconds (much faster than starting the VMs up from scratch by using up.sh or "vagrant up"). Another advantage of this is that you can always go back to the initial state without destroying other named snapshots that you created.
...