Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note: these steps have been tested on MacOS 10.911.56.

Install VirtualBox and Vagrant

...

  1. Download and install VirtualBox from https://www.virtualbox.org/wiki/Downloads. Note: as of 4/25/16 Vagrant doesn't work with the latest version of VirtualBox. We recommend installing an older (4.x) version of VirtualBox. This Quick Start has been tested on 4.3.34.

  2. Download and install Vagrant from https://www.vagrantup.com/downloads.html.
  3. Clone the ambari-vagrant GitHub repository into a convenient folder on your Mac. From the command-lineNavigate to the folder, and enter the following command from the terminal:

    Code Block
    git clone https://github.com/u39kun/ambari-vagrant.git
    

    The repository contains scripts for setting up Ambari virtual machines on several Linux distributions.

  4. Add virtual machine hostnames and addresses to the /etc/hosts file on your computer. The following command copies a set of host names and addresses from ambari-vagrant/append-to-etc-hosts.txt to the end of the /etc/hosts files:

    Code Block
    sudo -s 'cat ambari-vagrant/append-to-etc-hosts.txt >> /etc/hosts'
    
  5. Use the vagrant command to create a private key to use with Ambari:

    Code Block
    vagrant
    

    The vagrant command displays Vagrant command information, and then it creates a private key in the file ~/.vagrant.d/insecure_private_key.

...

  1.  Change your current directory to ambari-vagrant:

    Code Block
    cd ambari-vagrant
    

    If you run an ls command on the ambari-vagrant directory, you will see subdirectories for several different operating systems and operating system versions.

  2. 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 Quick Start example uses CentOS 7.0 . (To install and use a different version or distribution of Linux, specify the other directory name in place of centos7.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 a vagrant 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 uses centos7.0 , issue the following command:

    Code Block
    cp ~/.vagrant.d/insecure_private_key .
    
  3. (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 in Vagrantfile , increasing allocated memory from 3072 to 4096 or more; for example:

    Code Block
    vb.customize ["modifyvm", :id, "--memory", 4096] # RAM allocated to each VM
    
  4. Every virtual machine will have a directory called /vagrant inside the VM. This corresponds to the ambari-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.

  5. 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:
    - With the The default Vagrantfile (in each OS subdirectory) you can specify create up to 10 VMs. (If your computer can handle it; you can even add more.)virtual machines.
    - The fully-qualified domain name (FQDN) for each VM will have has the format <os-code>[01-10].ambari.apache.org, where <os-code> is c59 (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 will have has the format 192.168.<os-subnet>.1[01-10], where <os-subnet> is 59 64 for CentOS 56.94, 64 70 for CentOS 67.40, etcand so on. For example, 192.168.5970.101 will be the IP address for CentOS 57.9 0 node c5901 c7001.

    For example, the following command starts 3 VMs:
         ./up.sh 3
    Note: 
    For CentOS 7.0, the associated hostnames will be c7001, c7002, and c7003. Note that the up.sh 3 command is equivalent to vagrant up c640c700{1..3}. For CentOS 6. 4, the associated hostnames will be c6401, c6402, and c6403.

  6. Check the status of your VM(s). The following example shows the results of ./upsh 3 for three VMs running with CentOS 67.40:

    Code Block
    hw100:centos6.4 lkg$ vagrant status
    
    Current machine states:
    c6401c7001                     running (virtualbox)
    c6402c7002                     running (virtualbox)
    c6403c7003                     running (virtualbox)
    c6404c7004                     not created (virtualbox)
    c6405c7005                     not created (virtualbox)
    c6406c7006                     not created (virtualbox)
    c6407c7007                     not created (virtualbox)
    c6408c7008                     not created (virtualbox)
    c6409c7009                     not created (virtualbox)
    c6410c7010                     not created (virtualbox)

    Your virtual machines are now installed and running.

Accessing Virtual Machines

Use the following steps to access a running virtual machine:

  1. To log on to a virtual machine, use the vagrant ssh command; for (The vagrant init command initializes the current directory as a Vagrant environment; the initialization process should already be handled by the preceding steps.)
    Next, log into one of your VMs. For example:

    Code Block
    vagrant ssh c6401 c7001
    
    LMBP:centos7.0 lkg$ vagrant ssh c7001
    Last login: Tue Jan 12 11:20:28 2016
    [vagrant@c7001 ~]$  

    From this point onward, this terminal window will operate operates within the VM virtual machine until you you exit the VMvirtual machine. All commands will commands go to the VM, not to your Mac.

    Recommendation: Open a second terminal window for your Mac. This is useful when accessing the Ambari Web UI. To distinguish between the two, terminal windows typically list the computer name or VM hostname on each command-line prompt and at the top of the terminal window.

  2. When you first access the VM you will be logged in as user vagrant. Switch to the root user:

    Code Block
    sudo su -
    
  3. When you are finished using the VM, use the logout command to log out of root, and then use the exit command to return to your host machine (Mac). Note that the VMs will still be running in the background. If you plan to use the VMs again later, you can suspend each VM for later use (vagrant suspend <VM>) or snapshot their current state. Vagrant and snapshot commands are described later in this post.  (Note: http://help.skytap.com/VM_Sequencing.html?)

...