The Programmers Book

Pig Installation

Pre Requirements

1) A machine with Ubuntu 14.04 LTS operating system

2) Apache Hadoop 2.6.4 pre installed

3) Apache Pig 0.15.0 Software (Download Here)

Pig Installation

Installation Steps

Step 1 - Creating pig directory. Open a new terminal(CTRL + ALT + T) and enter the following command.

$ sudo mkdir /usr/local/pig

Step 2 - Change the ownership and permissions of the directory /usr/local/pig. Here 'hduser' is an Ubuntu username.

$ sudo chown -R hduser /usr/local/pig
$ sudo chmod -R 755 /usr/local/pig

Step 3 - Switch User, is used by a computer user to execute commands with the privileges of another user account.

$ su hduser

Step 4 - Change the directory to /home/hduser/Desktop , In my case the downloaded pig-0.15.0.tar.gz file is in /home/hduser/Desktop folder. For you it might be in /downloads folder check it.

$ cd /home/hduser/Desktop/

Step 5 - Untar the pig-0.15.0.tar.gz file.

$ tar xzf /home/hduser/Desktop/pig-0.15.0.tar.gz

Step 6 - Move the contents of pig-0.15.0 folder to /usr/local/pig

$ mv pig-0.15.0/* /usr/local/pig

Step 7 - Edit $HOME/.bashrc file by adding the pig path.

$ sudo gedit $HOME/.bashrc

$HOME/.bashrc file. Add the following lines

export PIG_HOME=/usr/local/pig
export PATH=$PIG_HOME/bin:$PATH
export PIG_CLASSPATH=$HADOOP_HOME/etc/hadoop

Step 8 - Reload your changed $HOME/.bashrc settings

$ source $HOME/.bashrc

Step 9 - Change the directory to /usr/local/pig/conf

$ cd /usr/local/pig/conf

Step 10 - Verify Pig Installation.

$ pig -version

Step 11 - Before fire up apache pig you need to start history server daemon of hadoop otherwise you will get some runtime exception. You can see that in the terminal.

Step 12 - Edit mapred-site.xml.


Step 13 - Add the following lines to mapred-site.xml. Dont forget to mention the host and port number for history server.


Step 14 - Change the directory to /usr/local/hadoop/sbin

$ cd /usr/local/hadoop/sbin

Step 15 - Start the History Server.

$ --config /usr/local/hadoop/etc/hadoop start historyserver

Step 16 - Change the directory to /usr/local/pig/bin

$ cd /usr/local/pig/bin

Step 17 - Enter into grunt shell in local mode.

$ ./pig -x local


Step 18 - Enter into grunt shell in MapReduce mode.

$ ./pig -x mapreduce

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *