Step 1: Download Pig tar file.
hduser@Soumitra-PC:~$ wget http://www-us.apache.org/dist/pig/pig-0.17.0/pig-0.17.0.tar.gz
Step 2: Extract the tar file using tar command.
In below tar command, x means extract an archive file, z means filter an archive through gzip, f means filename of an archive file.
hduser@Soumitra-PC:~$ tar -xzf pig-0.17.0.tar.gz
hduser@Soumitra-PC:~$ ls
Step 3: Move the extracted file to /usr/local/ directory
hduser@Soumitra-PC:~$ sudo mv /home/hduser/pig-0.17.0 /usr/local
Step 4: Edit the “~.bashrc” file to update the environment variables of Apache Pig.
hduser@Soumitra-PC:~$ sudo gedit ~/.bashrc
Add the following at the end of the file:
#PIG VARIABLES START
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PIG_HOME=/usr/local/pig-0.17.0
export PIG_HOME=/usr/local/pig-0.17.0
export PATH=$PATH:$PIG_HOME/bin
export PIG_CLASSPATH=$HADOOP_HOME_conf
export HADOOP_USER_CLASSPATH_FIRST=true
#PIG VARIABLES END
Also, make sure that hadoop path is also set.
Run the source command to make sure the changes get updated in the ~/.bashrc file.
hduser@Soumitra-PC:~$ source ~/.bashrc
Step 5: Check pig version.
hduser@Soumitra-PC:~$ pig -version
Step 6: Run Pig.
The Grunt shell can be started using the following command:
hduser@Soumitra-PC:~$ pig
Grunt Shell is used to run Pig Latin scripts.
Apache Pig can run in two modes, by default it chooses MapReduce mode. We can also run in MapReduce mode by writing the below command:
hduser@Soumitra-PC:~$ pig -x mapreduce
The other mode, local, can be run as:
hduser@Soumitra-PC:~$ pig -x local
References
https://www.edureka.co/blog/apache-pig-installation
Document prepared by Mr. Soumitra Ghosh
Assistant Professor, Information Technology,
C.V.Raman College of Engineering, Bhubaneswar
Contact: soumitraghosh@cvrce.edu.in
No comments:
Post a Comment