You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 23 Next »

Here is an overview of the four main steps for installing Ambari and HDP using VirtualBox and Vagrant:

  1. Install VirtualBox and Vagrant. (Installation only needs to be done once unless you want to upgrade VirtualBox and/or Vagrant.)
  2. Start one or more Linux virtual machines. Each machine represents a node in a cluster.
  3. Download, install, and deploy the version of Ambari you wish to use.
  4. Using Ambari, deploy the version of HDP you wish to use. 

Once VirtualBox and Vagrant have been installed, steps 2 through 4 can be done multiple times (to change versions, create a larger cluster, etc.).

Note: these steps have been tested on MacOS 10.9.5.

Install VirtualBox and Vagrant

VirtualBox allows you to run multiple operating systems (inside multiple virtual machines) at the same time. Your Mac is the "host" machine, and the virtual machines are called "guest" machines.

In this Quick Start you will use VirtualBox to run Linux nodes within VirtualBox on OS X:   consider iterating/revising the image

Vagrant is a tool that makes it easier to work with virtual machines. It helps automate the work of setting up, running, and removing virtual machine environments. Using Vagrant, you can install and run a preconfigured cluster environment with Ambari and the HDP stack.

  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-line:

    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:

    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:

    vagrant
    

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

Start Linux Virtual Machines

The ambari-vagrant directory (cloned from GitHub) contains several subdirectories, each for a specific Linux distribution. Each subdirectory has scripts and configuration files for running Ambari and HDP on that version of Linux.

To start one or more virtual machines:

  1.  Change your current directory to ambari-vagrant:

    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 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.)

    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:

    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:

    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.

    ./up.sh <# of VMs to launch>
    

    Additional notes:
    - With the default Vagrantfile (in each OS subdirectory) you can specify up to 10 VMs. (If your computer can handle it; you can even add more.)
    - The fully-qualified domain name (FQDN) for each VM will have 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 the format 192.168.<os-subnet>.1[01-10], where <os-subnet> is 59 for CentOS 5.9, 64 for CentOS 6.4, etc. For example, 192.168.59.101 will be the IP address for CentOS 5.9 node c5901.

    For example, the following command starts 3 VMs:
         ./up.sh 3

    Note:  up.sh 3 is equivalent to vagrant up c640{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 6.4:

    hw100:centos6.4 lkg$ vagrant status
    
    Current machine states:
    c6401                     running (virtualbox)
    c6402                     running (virtualbox)
    c6403                     running (virtualbox)
    c6404                     not created (virtualbox)
    c6405                     not created (virtualbox)
    c6406                     not created (virtualbox)
    c6407                     not created (virtualbox)
    c6408                     not created (virtualbox)
    c6409                     not created (virtualbox)
    c6410                     not created (virtualbox)

    (The vagrant init command initializes the current directory as a Vagrant environment; the initialization process should already be handled by the preceding steps.)

  7. Next, log into one of your VMs. For example:

    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 within the VM until you exit the VM. All commands will 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.

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

    sudo su -
    
  9. When you are finished using the VM, 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.  

Install Ambari

Prerequisites: Before installing Ambari, the following software must be installed on your VM:

  • yum

  • rpm

  • scp

  • curl

  • wget

  • pdsh

  • ntpd?

(how to check)

  1. From the terminal window on your VM (where the main ambari service should run?), download the Ambari repository. The following commands download Ambari version 2.2.1.0 and install ambari-server:

    OSCommands
    CentOS 6
    wget -O /etc/yum.repos.d/ambari.repo http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.2.1.0/ambari.repo
    yum install ambari-server -y
    CentOS 7wget -O /etc/yum.repos.d/ambari.repo http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.2.1.0/ambari.repo
    yum install ambari-server -y
    Ubuntu 12
    wget -O /etc/apt/sources.list.d/ambari.list http://public-repo-1.hortonworks.com/ambari/ubuntu12/2.x/updates/2.2.1.0/ambari.list
    apt-key adv --recv-keys --keyserver keyserver.ubuntu.com B9733A7A07513CAD apt-get update apt-get install ambari-server -y
     Ubuntu 14wget -O /etc/apt/sources.list.d/ambari.list http://public-repo-1.hortonworks.com/ambari/ubuntu14/2.x/updates/2.2.1.0/ambari.list
    apt-key adv --recv-keys --keyserver keyserver.ubuntu.com B9733A7A07513CAD
    apt-get update
    apt-get install ambari-server -y

    Note: to run a different version of Ambari, specify the repo URL for the version.

  2. To install Ambari with default settings, set up and start ambari-server:

    ambari-server setup -s
    ambari-server start

    For more information about installation options, see Ambari User Guides.

  3. (Optional) For frontend developers only: see "Frontend Development" (later on this page) for extra setup instructions.

  4. Once Ambari Server is started, access the Ambari Web UI at http://<hostname>.ambari.apache.org:8080. For example:

    http://c6401.ambari.apache.org:8080

    The URL depends on the OS and the node where you installed Ambari
    Note: The Ambari Server can take some time to launch and be ready to accept connections. Keep trying the URL until you see the login page.

  5. Login using default username admin, password admin.

  6. Choose "Launch Install Wizard."

  7. Name your cluster.

  8. On the Install Options page, list the FQDNs of the VMs. For example:

    c6401.ambari.apache.org
    c6402.ambari.apache.org
    c6403.ambari.apache.org
    

    Alternatively, you can use a range expression:

    c64[01-03].ambari.apache.org
    
  9. Upload the insecure_private_key file that you created earlier.

  10. Specify non-root SSH user vagrant.

  11. Follow the onscreen instructions to install your cluster.

Install the HDP Stack

Next, install HDP on your cluster.

http://docs.hortonworks.com/HDPDocuments/Ambari-2.2.1.0/bk_Installing_HDP_AMB/content/ch_Deploy_and_Configure_a_HDP_Cluster.html

Choose which HDP version,  Choose services, Assign master and slave processes, Customize services (here I assigned admin/admin to Hive and Oozie)

Timeline for installing HDP, and mac hardware

 

Troubleshooting

 

Other tips:

 

  • yum failed? install yum on your VMs.
  • Ambari message about THPs? fix transparent huge page setting in /etc/rc.loca (CentOS7)
  • ntpd not installed?

Basic Vagrant Commands

The following table lists several common Vagrant commands. For more information, see Vagrant Command-Line Interface documentation.

CommandDescription
vagrant up <vm-name>

Starts a specific VM. (up.sh is a wrapper for this call.) You can use this command to start more VMs after you called up.sh.

Example: vagrant up c6406

Note: if you do not specify the <vm-name> parameter, it will try to start ten VMs.

vagrant status [<vm-name>]Shows which VMs are running, suspended, etc.
vagrant destroy -f [<vm-name>]

Destroys all VMs launched from the current directory, and deletes them from disk.

Optional: Specify a specific VM to destroy.

vagrant suspend [<vm-name>]

Suspends (snapshot) all VMs launched from the current directory so that you can resume them later

Optional: Specify a specific VM to suspend.

vagrant resume [<vm-name>]

Resumes all suspended VMs launched from the current directory

Optional: Specify a specific VM to resume.

vagrant ssh <vm-name>

Starts a SSH session to the host.

Example: vagrant ssh c6401

vagrant --helpList information about Vagrant commands.

Taking Snapshots

A Vagrant snapshot saves the current state of a VM, so that you can re-run the VM from the same point at a future time.

Vagrant makes it easy to take snapshots of the entire cluster.
First, install the snapshot plugin:

vagrant plugin install vagrant-vbox-snapshot --plugin-version=0.0.2

This enables the “vagrant snapshot” command. Note that the above installs vesion 0.0.2. if you install the latest plugin version 0.0.3 does not allow taking snapshots of the whole cluster at the same time (you have to specify a VM name).
Run vagrant snapshot to see the syntax.
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 c64[01-03].
Note: Upon resuming a snapshot, you may find that time-sensitive services may be down (e.g, HBase RegionServer is down, etc.)

Tip: After starting the VMs but before you do 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.

Misc

To test OS’s other than what’s currently in the ambari-vagrant repo, please see http://www.vagrantbox.es/ for the readily available OS images you can test. Note that Ambari currently works on RHEL 5/6, CentOS 5/6, Oracle Linux 5/6, SUSE 11, and SLES 11. Ubuntu support is work in progress.

Pre-Configured Development Environment

Simply edit Vagrantfile to launch a VM with all the tools necessary to build Ambari from source.

cd ambari-vagrant/centos6.4
vi Vagrantfile  <- uncomment the line with "dev-bootstrap.sh"
vagrant up c6401

To build from source, follow the instructions in Ambari Development.

Frontend Development

You can use this set up to develop and test out Ambari Web frontend code against a real Ambari Server on a multi-node environment.

On the host machine:

cd ambari-vagrant/centos6.4
git clone https://git-wip-us.apache.org/repos/asf/ambari.git ambari
cd ambari/ambari-web
npm install
brunch w

On c6401 (where Ambari Server is installed):

cd /usr/lib/ambari-server
mv web web-orig
ln -s /vagrant/ambari/ambari-web/public web
ambari-server restart

With this setup, whenever you change the content of ambari-web files (under ambari-vagrant/ambari/) on the host machine, brunch will pick up changes in the background and update ambari-vagrant/ambari/ambari-web/public.  Because of the symbolic link, the changes are automatically picked up by Ambari Server.  All you have to do is hit refresh on the browser to see the frontend code changes reflected.

Not seeing code changes as expected?  If you have run the maven command to build Ambari previously, you will see files called app.js.gz and vendor.js.gz under the public folder.  You need to delete these files for the frontend code changes to be effective, as the app.js.gz and vendor.js.gz files take precedence over app.js and vendor.js, respectively.

 

  • No labels