Thursday, February 28, 2013

Eclipse Plugin For Hadoop

Hi Friends,

Today I want to write about how to build an eclipse plugin...as I faced so much trouble in building it so I want to compile all the steps that I have taken to build it.

1. Install Hadoop 1.0.4 and perform all the setup steps as specified in this  --- LINK 
    I performed the setup for Pseudo-Distributed Operation
   
    I comes with source code of eclipse plugin and build file for building it.

2. Install Eclipse Galileo or as document say you need to get at least eclipse version greater then 3.4

I did all the installation and building process on virtual machine running Ubuntu 10.04 LTS

Lets start then:

0. I hope everyone have hadoop and eclipse installed it on there system

1. Install Apache Forrest 0.8 tar.gz (It has to be version 0.8 no other version will work)   --- LINK

2. Get Java version 5 update 22 (You specifically need version 5 only otherwise it will not work)  ---LINK

3. Go to src/contib/eclipse_plugin folder  then open build.properties using "nano build.properties"
   
   In it we need to set the path to eclipse...append following to the end of file:
      "eclipse.home =  /usr/lib/eclipse/"

  I have my eclipse folder in /usr/lib/ with the name eclipse.

4. Now either copy using cp these jars from ${hadoop}/lib to ${jar}/lib or Follow Step 5 
  • commons-cli-1.2.jar
  • commons-configuration-1.6.jar
  • jackson-core-asl-1.8.8.jar
  • jackson-mapper-asl-1.8.8.jar
  • commons-httpclient-3.0.1.jar
  • commons-lang-2.4.jar
5. Add following code to ${eclipse-plugin-src}/build.xml target jar
<copy file="${hadoop.root}/build/ivy/lib/Hadoop/common/commons-cli-${commons-cli.version}.jar"  todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-configuration-${commons-configuration.version}.jar"  todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-httpclient-${commons-httpclient.version}.jar"  todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-lang-${commons-lang.version}.jar"  todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/jackson-core-asl-${jackson.version}.jar"  todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/jackson-mapper-asl-${jackson.version}.jar"  todir="${build.dir}/lib" verbose="true"/>

***Step 6 need to be followed in both case i.e. either you use step 5 or step 4..I recommend use Step 5

6. Modify following to MANIFEST file:

bundle-ClassPath: classes/,
 lib/hadoop-core.jar,
 lib/commons-cli-1.2.jar,
 lib/commons-configuration-1.6.jar,
 lib/jackson-core-asl-1.8.8.jar,
 lib/commons-httpclient-3.0.1.jar,
 lib/jackson-mapper-asl-1.8.8.jar,
 lib/commons-lang-2.4.jar

7. Now we can run the command to build our eclipse plugin
 
    come out of  > hadoop/src/contib/eclipse_plugin folder to >hadoop folder

   Use following command to build eclipse plugin

   ant clean package -Djava5.home=/opt/java/jdk1.5.0_22 -Dforrest.home=/opt/apache-forrest-0.8    

   /opt/java/jdk1.5.0_22 is the place where I installed my jdk 5 and /opt/apache-forrest-0.8 is the place  where I installed forrest 0.8

In the end it might give you build failure but do not worry eclipse plugin jar will be in
>hadoop/build/contrib/eclipse-plugin

8. Now you can copy this plugin to your eclipse -> plugin folder and start eclipse and go to open perspective and select Map Reduce (as soon as you see Map reduce means your plugin was successful)

Enjoy!!!

I hope you find this post informative please email me post comment if you face any problem and then we will solve the problem together :)

Monday, February 11, 2013

Linux Kernal Compilation and Installation

Today I will write about how to install the Linux Kernel:

Requirements:

1. Install Oracle VM virtual box. LINK
2. Create new virtual machine  from "Ubuntu 10.0.4 Desktop".
3. Download "linux-2.6.9.tar.bz2" from Linux Kernel archives. LINK

To check the version of current installed Kernel on Ubuntu use following command:

uname -a

Now for installing this Kernel we need different version of gcc compiler. In Ubuntu 10.0.4 we have different version of gcc compiler which you can see by typing

gcc -v

We need gcc 3.4 version. For this download following files from this LINK:

-  cpp-3.4_3.4.6-6ubuntu3_i386.deb
-  gcc-3.4_3.4.6-6ubuntu3_i386.deb
-  gcc-3.4-base _3.4.6-6ubuntu3_i386.deb

Use the following command to install these packages 

sudo dpkg -i *.deb

Now we have two compilers on our system
gcc-4.4 and gcc-3.4

To use gcc-3.4 compiler you can use it as

gcc-3.4 foo.c -o foo.out

Once all the packages are installed now we need to change our default compiler to point to gcc-3.4 version. For this we need to be in "root" mode

sudo -s

Above command will take you in the root mode.

The command GCC it is actually a symbolic link to which ever version of GCC you are using. What this means is we can create a symbolic link from GCC to whichever version of GCC we want.

  • You can see the symbolic link :
ls -la /usr/bin | grep gcc-4.4
  • So what we need to do is remove the GCC symlink and the G++ symlink and then recreate them linked to GCC 3.4:
rm /usr/bin/gcc

ln -s /usr/bin/gcc-3.4 /usr/bin/gcc
  • Now if we check the symbolic links again we will see GCC & G++ are now linked to GCC 3.4:
ls -la /usr/bin/ | grep gcc
  • Finally we can check our GCC -v again and make sure we are using the correct version:
gcc -v
 Awesome, so we set the gcc 3.4 version as our default version.

Now lets work on the tar we downloaded "linux-2.6.9.tar.bz2"

1. untar the archive file using following command:

tar -xjvf linux-2.6.9.tar.bz2

2. get into the folder that is created after above command lets say it is linux-2.6.9

../linux-2.6.9$

3. Now we need to install ncurses-dev use following command

../linux-2.6.9$> sudo apt-get install ncurses-dev

This will install all the dependencies that is required to compile the kernel

4. Install the following patch otherwise it will give assembly 'mov' problems

download linux-2.6-seg-5.patch from LINK

apply this patch using following command:

 ../linux-2.6.9$> sudo patch -p1 < ../linux-2.6-seg-5.patch

5. Now we are good to go and compile our kernel.

Follow the following steps to compile the kernel:

a) configure your kernel using the following command


 ../linux-2.6.9$>make menuconfig

Normally, you can also use “$> make xconfig” or “$> make gconfig” to configure your kernel.

When you configure the kernel according to your need try to browse all the component. Generally, for each component, you can choose one of the three options: [*] built-in, [ ] excluded, or <M> module. For built-in option, the component will be compiled and built into the kernel so that it will be in the kernel whenever the kernel boots up. For module option, the component will be compiled and can be dynamically loaded/unloaded into/from the running kernel. For excluded option, the component will not be compiled at all.

At the end of this configuration, the file will be saved as ./.config. In this configuration process, you need to select “excluded” for all the “Device Drivers” -->  “SCSI device support” --> “Qlogic xxxxxxx support”. Otherwise, the compilation will fail. I am not sure what is the reason for it but I will find it and update this post.

You can change the name of kernel by modifying ./Makefile. You can append "somename" to the line “EXTRAVERSION=”.

b) Compile your kernel using 

../linux-2.6.9$> make

c) compile kernel modules using 

../linux-2.6.9$>make modules

d) Install your kernel modules using 

../linux-2.6.9$> make modules_install

e) Then you can install the newly-compiled kernel using 

../linux-2.6.9$> make install 

which will install the kernel, the symbol file,and the boot image into /boot directory.

f)
you may modify the grub file at /boot/grub/menu.lst, which will decide what kernel
image should be used at the booting time. You should change the default value to the newly compiled
kernel. The number starts from 0.

Finally, you can reboot your virtual machine (do not power off, just reboot it).

To Test which kernel is booted you can type following command in terminal:

$> uname -a

This command will show you the exact version number. If it is “2.6.9somename”, you are ready to go.