Wednesday, December 10, 2014

Installing Ambari from scratch using Vagrant. Step by Step


Being a developer it a pain to configure hadoop every time.
I wanted a process that is easily reproducible.
So at a high level steps involved are:
# FDQN
# Password Less SSH, Disable SELINUX , iptables Off
# NTP
# yum -y install ntp
# wget http://public-repo-1.hortonworks.com/ambari/centos6/1.x/updates/1.5.1/ambari.repo
# cp ambari.repo /etc/yum.repos.d
# yum install ambari-server
# ambari-server setup
# ambari-server start
# Start Ambari in browser u/n admin , pwd admin
# If Somthing Goes Wrong
#‘yum erase ambari-agent’ and ‘yum erase ambari-server’
view raw ambari hosted with ❤ by GitHub

Make sure you have vagrant installed
Config : 3 node , 3.4GB, 1 core each
1 master, 2 slaves
Create a vagrant file (Make sure you have more than 10GB Ram)
Vagrant::Config.run do |config|
config.vm.box = "centos65"
config.vm.customize [
"modifyvm", :id,
"--memory", "3427"
]
config.vm.define :hadoop1 do |hadoop1_config|
hadoop1_config.vm.network :hostonly, "10.10.0.53"
hadoop1_config.vm.host_name = "hdp.hadoop1.com"
end
config.vm.define :hadoop2 do |hadoop2_config|
hadoop2_config.vm.network :hostonly, "10.10.0.54"
hadoop2_config.vm.host_name = "hdp.hadoop2.com"
end
config.vm.define :hadoop3 do |hadoop3_config|
hadoop3_config.vm.network :hostonly, "10.10.0.55"
hadoop3_config.vm.host_name = "hdp.hadoop3.com"
end
end
view raw Vagrantfile hosted with ❤ by GitHub

after creating this file all you need to do is 'vagrant up'

Step 1: FDQN
http://en.wikipedia.org/wiki/Fully_qualified_domain_name
change vi /etc/hosts

prepend with following entries
10.10.0.53   hdp.hadoop1.com hadoop1
10.10.0.54   hdp.hadoop2.com hadoop2
10.10.0.55   hdp.hadoop3.com hadoop3

(In All three nodes)
you should be able to ssh using domain names + 'hostname -f' returns fdqn for that machine

Install NTP and NTPD in all nodes

Use the script below to prepare your cluster
./prepare-cluster.sh hosts.txt
hdp.hadoop1.com
hdp.hadoop2.com
hdp.hadoop3.com
view raw host hosted with ❤ by GitHub

#!/bin/bash
set -x
# Generate SSH keys
ssh-keygen -t rsa
cd ~/.ssh
cat id_rsa.pub >> authorized_keys
cd ~
# Distribute SSH keys
for host in `cat hosts.txt`; do
cat ~/.ssh/id_rsa.pub | ssh root@$host "mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys"
cat ~/.ssh/id_rsa | ssh root@$host "cat > ~/.ssh/id_rsa; chmod 400 ~/.ssh/id_rsa"
cat ~/.ssh/id_rsa.pub | ssh root@$host "cat > ~/.ssh/id_rsa.pub"
done
# Distribute hosts file
for host in `cat hosts.txt`; do
scp /etc/hosts root@$host:/etc/hosts
done
# Prepare other basic things
for host in `cat hosts.txt`; do
ssh root@$host "sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config"
ssh root@$host "chkconfig iptables off"
ssh root@$host "/etc/init.d/iptables stop"
echo "enabled=0" | ssh root@$host "cat > /etc/yum/pluginconf.d/refresh-packagekit.conf"
done
view raw prepare-cluster hosted with ❤ by GitHub

And Vola . Just run the commands below.
# wget http://public-repo-1.hortonworks.com/ambari/centos6/1.x/updates/1.5.1/ambari.repo
# cp ambari.repo /etc/yum.repos.d
# yum install ambari-server
# ambari-server setup
# ambari-server start
# Start Ambari in browser u/n admin , pwd admin
view raw Ambari hosted with ❤ by GitHub

PS : Make sure you had entries to the hosts in Windows. Remember to check if the hostname is pingable from windows.

ping hdp.hadoop1.com

URL : hdp.hadoop1.com:8080

No comments:

Post a Comment