AdSense

Sunday, 2 February 2014

Hadoop and Ubuntu - step 2 - Install Oracle Java for Hadoop setup.

In the step 1 of the set up available here, we took a look at installation of Linux based OS (Ubuntu) for Hadoop as we opted for Linux instead of Windows for Hadoop. We also saw the reasons for the preference.
STEP 1- Choose and configure (Linux) OS of choice on Machine of Choice
00
STEP 2 - Install Java and configure it on the machine
Available choices for Java are OpenJDK or Oracle JAVA. I preferred Oracle Java. Follow the below instructions for Oracle Java configuration on Ubuntu.

Download the Oracle Java from its own official download page. Version should be compatible with your OS and machine type (32 or 64 bit). It will be now in some folder as Downloads.

Uncompress it from Terminal window using

tar -xvf jdk-7u2-linux-x64.tar.gz

The uncompressed directory (name depends on downloaded version, here jdk1.7.0) should be in /usr/lib under jvm. So lets move it there using. Only JRE will be available as Software through official Ubuntu. We need latest JRE with latest JDK from Oracle, hence we download.
sudo mkdir -p /usr/lib/jvm


sudo mv ./jdk1.7.0_02 /usr/lib/jvm/jdk1.7.0

Set environment variables for Java. Open and append file /etc/profile with below code
JAVA_HOME=/usr/local/java/jdk1.7.0_45


PATH=$PATH:$HOME/bin:$JAVA_HOME/bin


JRE_HOME=/usr/local/java/jdk1.7.0/jre


PATH=$PATH:$HOME/bin:$JRE_HOME/bin


export JAVA_HOME


export JRE_HOME


export PATH


Reboot now. After this, Ubuntu has to know that JDK is available; so run below commands
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1


sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1


sudo update-alternatives --config java


Do the same for Javac. That's it, done. You can now check for Java and Javac version as

java -version

java version "1.7.0"


Java(TM) SE Runtime Environment (build 1.7.0-b147)


Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode) 


This completes step 2. You can also learn about usage of Hadoop and about Hadoop architecture on BabaGyan.com.