Categories: Hadoop

Hadoop Installation Tutorial (Hadoop 1.x)

<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<p><b>Software Required-<&sol;b><br &sol;>&NewLine;<b>Setup Virtual Machine<&sol;b><&sol;p>&NewLine;<p><b>Step1&period;<&sol;b> &gt&semi;goto<b><a href&equals;"http&colon;&sol;&sol;traffictool&period;net&sol;" target&equals;"&lowbar;blank" rel&equals;"noopener"> traffictool&period;net<&sol;a><&sol;b>-&gt&semi;goto ubuntu&lpar;Ubuntu1404&rpar;-&gt&semi;download it-&gt&semi;extract it<&sol;p>&NewLine;<p><b>Step2&period;<&sol;b> Suppose your directory after extract it<br &sol;>&NewLine;<i>&&num;8220&semi;D&colon;personal datahadoopUbuntu1404&&num;8221&semi; <&sol;i><&sol;p>&NewLine;<p><b>Step3&period;<&sol;b> &gt&semi;goto google-&gt&semi;search VMWARE PLAYER-&gt&semi;goto result select DESKTOP &amp&semi; END USER-&gt&semi;<b><a href&equals;"https&colon;&sol;&sol;my&period;vmware&period;com&sol;web&sol;vmware&sol;info&sol;slug&sol;desktop&lowbar;end&lowbar;user&lowbar;computing&sol;vmware&lowbar;horizon&lowbar;with&lowbar;view&sol;6&lowbar;0" target&equals;"&lowbar;blank" rel&equals;"noopener">download it<&sol;a><&sol;b>-&gt&semi;install it<&sol;p>&NewLine;<p><b>Step4&period;<&sol;b> After installation of virtual machine goto-&&num;8220&semi;<i>D&colon;personal datahadoopUbuntu1404<&sol;i>&&num;8221&semi;<&sol;p>&NewLine;<div id&equals;"ads-id" align&equals;"center"><&sol;div>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2014&sol;11&sol;ubntu&period;jpg" width&equals;"640" height&equals;"271" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>Step5&period;<&sol;b> double click &&num;8220&semi;Ubuntu&period;vmx&&num;8221&semi; then virtual is running after that open now as following&period;<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2014&sol;11&sol;ubntu-1&period;jpg" width&equals;"640" height&equals;"507" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>Step6&period;<&sol;b> -&gt&semi;&gt&semi;Through the VM machine<b><a href&equals;"http&colon;&sol;&sol;hadoop&period;apache&period;org&sol;&num;Download&plus;Hadoop" target&equals;"&lowbar;blank" rel&equals;"noopener"> download hadoop release<&sol;a><&sol;b> Hadoop-1&period;2&period;1&lpar;61M&rpar; &gt&semi;&gt&semi; extract it &&num;8220&semi;<b>hadoop-1&period;2&period;1&period;tar&period;gz<&sol;b>&&num;8221&semi;<&sol;p>&NewLine;<p><b>Step7&period;<&sol;b> In this tutorial Hadoop install into following location<&sol;p>&NewLine;<p><i><b>&sol;home&sol;user&sol;hadoop-1&period;2&period;1 <&sol;b><&sol;i><br &sol;>&NewLine;<b>Step8&period;<&sol;b> -&gt&semi;&gt&semi;install Java in Linux<br &sol;>&NewLine;<b><i>sudo apt-get install openjdk-7-jdk <&sol;i><&sol;b><&sol;p>&NewLine;<p><b>Step9&period;<&sol;b> In this tutorial JDK install into following location<br &sol;>&NewLine;<i><b>&sol;usr&sol;lib&sol;jvm&sol;java-7-openjdk-i386<&sol;b><&sol;i><br &sol;>&NewLine;<i><b><&sol;b><&sol;i><br &sol;>&NewLine;Hadoop mainly consists of two parts&colon; Hadoop MapReduce and HDFS&period; Hadoop MapReduce is a programming model and software framework for writing applications&comma; which is an open-source variant of MapReduce that is initially designed and implemented by Google for processing and generating large data sets&period; HDFS is Hadoop’s underlying data persistency layer&comma; which is loosely modelled after Google file system GFS&period; Hadoop has seen active development activities and increasing adoption&period; Many cloud computing services&comma; such as Amazon EC2&comma; provide MapReduce functions&comma; and the research community uses MapReduce and Hadoop to solve data-intensive problems in bioinformatics&comma; computational finance&comma; chemistry&comma; and environmental science&period; Although MapReduce has its limitations&comma; it is an important framework to process large data sets&period;<&sol;p>&NewLine;<p>How to set up a Hadoop environment in a cluster is introduced in this tutorial&period; In this tutorial&comma; we set up a Hadoop cluster&comma; one node runs as the NameNode&comma; one node runs as the JobTracker and many nodes runs as the TaskTracker &lpar;slaves&rpar;&period;<&sol;p>&NewLine;<p><b>Step10&period; Enable &&num;8220&semi;hadoop&&num;8221&semi; user to password-less SSH login to slaves-<&sol;b><br &sol;>&NewLine;Just for our convenience&comma; make sure the &&num;8220&semi;hadoop&&num;8221&semi; user from NameNode and JobTracker can ssh to the slaves without password so that we need not to input the password every time&period;<&sol;p>&NewLine;<p>Details about <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2014&sol;11&sol;enabling-password-less-ssh-login&period;html" target&equals;"&lowbar;blank" rel&equals;"noopener">password-less SSH login can be found Enabling Password-less ssh Login<&sol;a>&period;<&sol;p>&NewLine;<p><b>Step11&period; Hadoop Configuration<&sol;b><br &sol;>&NewLine;<b>Configure environment variables of &OpenCurlyDoubleQuote;hadoop” user <&sol;b><br &sol;>&NewLine;Open terminal of command prompt and set environment  variable as follows<&sol;p>&NewLine;<p><b>export<&sol;b><i><b> JAVA&lowbar;HOME&equals;&sol;usr&sol;lib&sol;jvm&sol;java-7-openjdk-i386<&sol;b><&sol;i><br &sol;>&NewLine;<b>export<&sol;b><i><b> JAVA&lowbar;INSTALL&equals;<&sol;b><b>&sol;home&sol;user&sol;hadoop-1&period;2&period;1 <&sol;b><&sol;i><br &sol;>&NewLine;and Hadoop Path assign follows<br &sol;>&NewLine;<b>export<&sol;b><i><b> HADOOP&lowbar;COMMON&lowbar;HOME&equals;&&num;8221&semi;&sol;home&sol;hadoop&sol;hadoop&sol;&&num;8221&semi;<&sol;b><&sol;i><br &sol;>&NewLine;<b>export<&sol;b><i><b> PATH&equals;&dollar;HADOOP&lowbar;COMMON&lowbar;HOME&sol;bin&sol;&colon;&dollar;PATH<&sol;b><&sol;i><&sol;p>&NewLine;<p>The HADOOP&lowbar;COMMON&lowbar;HOME environment variable is used by Hadoop’s utility scripts&comma; and it must be set&comma; otherwise the scripts may report an error message &&num;8220&semi;Hadoop common not found&&num;8221&semi;&period;<&sol;p>&NewLine;<p>The second line adds hadoop’s bin directory to the PATH sothat we can directly run hadoop’s commands without specifying the full path to it&period;<&sol;p>&NewLine;<p><b>Step12&period; Configure Important files for Hadoop<&sol;b><br &sol;>&NewLine;<b>A&period; &sol;home&sol;user&sol;hadoop-1&period;2&period;1&sol;conf&sol;hadoop-env&period;sh<&sol;b><br &sol;>&NewLine;Add or change these lines to specify the JAVA&lowbar;HOME and directory to store the logs&colon;<&sol;p>&NewLine;<p>export <i><b>JAVA&lowbar;HOME&equals;&sol;usr&sol;lib&sol;jvm&sol;java-7-openjdk-i386<&sol;b><&sol;i><br &sol;>&NewLine;export <i><b>HADOOP&lowbar;LOG&lowbar;DIR&equals;&sol;home&sol;user&sol;hadoop-1&period;2&period;1&sol;logs<&sol;b><&sol;i><&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2014&sol;11&sol;ubuntu&period;jpg" width&equals;"640" height&equals;"383" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>B&period; <i>&sol;home&sol;user&sol;hadoop-1&period;2&period;1&sol;conf&sol;core-site&period;xml <&sol;i>&lpar;configuring NameNode&rpar;<&sol;b><br &sol;>&NewLine;Here the <b>NameNode <&sol;b>runs on 127&period;1&period;1&period;1&period; or localhost<&sol;p>&NewLine;<pre class&equals;"highlight">&lt&semi;&quest;xml version&equals;"1&period;0"&quest;&gt&semi; &NewLine;&lt&semi;&quest;xml-stylesheet type&equals;"text&sol;xsl" href&equals;"configuration&period;xsl"&quest;&gt&semi; &NewLine; &NewLine;&lt&semi;&excl;-- Put site-specific property overrides in this file&period; --&gt&semi; &NewLine; &NewLine;&lt&semi;configuration&gt&semi; &NewLine;&lt&semi;property&gt&semi; &NewLine; &lt&semi;name&gt&semi;fs&period;default&period;name&lt&semi;&sol;name&gt&semi; &NewLine; &lt&semi;value&gt&semi;hdfs&colon;&sol;&sol;localhost&colon;9000&lt&semi;&sol;value&gt&semi; &NewLine; &lt&semi;&sol;property&gt&semi; &NewLine;&lt&semi;&sol;configuration&gt&semi; &NewLine;<&sol;pre>&NewLine;<p><b>C&period; <i>&sol;home&sol;user&sol;hadoop-1&period;2&period;1&sol;conf&sol;hdfs-site&period;xml <&sol;i>&lpar;Configuring DataNode&rpar;<&sol;b><br &sol;>&NewLine;dfs&period;replication is the number of replicas of each block&period; dfs&period;name&period;dir is the path on the local filesystem where the NameNode stores the namespace and transactions logs persistently&period; dfs&period;data&period;dir is comma-separated list of paths on the local filesystem of a DataNode where it stores its blocks&period;<&sol;p>&NewLine;<pre class&equals;"highlight">&lt&semi;&quest;xml version&equals;"1&period;0"&quest;&gt&semi; &NewLine;&lt&semi;&quest;xml-stylesheet type&equals;"text&sol;xsl" href&equals;"configuration&period;xsl"&quest;&gt&semi; &NewLine; &NewLine;&lt&semi;&excl;-- Put site-specific property overrides in this file&period; --&gt&semi; &NewLine; &NewLine;&lt&semi;configuration&gt&semi; &NewLine;&lt&semi;property&gt&semi; &NewLine; &lt&semi;name&gt&semi;dfs&period;http&period;address&lt&semi;&sol;name&gt&semi; &NewLine; &lt&semi;value&gt&semi;localhost&colon;50070&lt&semi;&sol;value&gt&semi; &NewLine; &lt&semi;&sol;property&gt&semi; &NewLine; &NewLine;&lt&semi;property&gt&semi; &NewLine;&lt&semi;name&gt&semi;dfs&period;replication&lt&semi;&sol;name&gt&semi; &NewLine;&lt&semi;value&gt&semi;3&lt&semi;&sol;value&gt&semi; &NewLine;&lt&semi;&sol;property&gt&semi; &NewLine; &NewLine;&lt&semi;property&gt&semi; &NewLine;&lt&semi;name&gt&semi;dfs&period;name&period;dir&lt&semi;&sol;name&gt&semi; &NewLine;&lt&semi;value&gt&semi;&sol;lhome&sol;hadoop&sol;data&sol;dfs&sol;name&sol;&lt&semi;&sol;value&gt&semi; &NewLine;&lt&semi;&sol;property&gt&semi; &NewLine; &NewLine;&lt&semi;property&gt&semi; &NewLine;&lt&semi;name&gt&semi;dfs&period;data&period;dir&lt&semi;&sol;name&gt&semi; &NewLine;&lt&semi;value&gt&semi;&sol;lhome&sol;hadoop&sol;data&sol;dfs&sol;data&sol;&lt&semi;&sol;value&gt&semi; &NewLine;&lt&semi;&sol;property&gt&semi; &NewLine;&lt&semi;&sol;configuration&gt&semi; &NewLine;<&sol;pre>&NewLine;<p><b>D&period; <i>&sol;home&sol;user&sol;hadoop-1&period;2&period;1&sol;conf&sol;mapred-site&period;xml <&sol;i>&lpar;Configuring JobTracker&rpar;<&sol;b><br &sol;>&NewLine;Here the JobTracker runs on 127&period;1&period;1&period;0&period; or localhost<&sol;p>&NewLine;<pre class&equals;"highlight">&lt&semi;&quest;xml version&equals;"1&period;0"&quest;&gt&semi; &NewLine;&lt&semi;&quest;xml-stylesheet type&equals;"text&sol;xsl" href&equals;"configuration&period;xsl"&quest;&gt&semi; &NewLine; &NewLine;&lt&semi;&excl;-- Put site-specific property overrides in this file&period; --&gt&semi; &NewLine; &NewLine;&lt&semi;configuration&gt&semi; &NewLine;&lt&semi;property&gt&semi; &NewLine; &lt&semi;name&gt&semi;mapreduce&period;jobhistory&period;address&lt&semi;&sol;name&gt&semi; &NewLine; &lt&semi;value&gt&semi;localhost&colon;10020&lt&semi;&sol;value&gt&semi; &NewLine; &lt&semi;&sol;property&gt&semi; &NewLine; &NewLine;&lt&semi;property&gt&semi; &NewLine;&lt&semi;name&gt&semi;mapred&period;job&period;tracker&lt&semi;&sol;name&gt&semi; &NewLine;&lt&semi;value&gt&semi;10&period;1&period;1&period;2&colon;9001&lt&semi;&sol;value&gt&semi; &NewLine;&lt&semi;&sol;property&gt&semi; &NewLine; &NewLine;&lt&semi;property&gt&semi; &NewLine;&lt&semi;name&gt&semi;mapred&period;system&period;dir&lt&semi;&sol;name&gt&semi; &NewLine;&lt&semi;value&gt&semi;&sol;hadoop&sol;data&sol;mapred&sol;system&sol;&lt&semi;&sol;value&gt&semi; &NewLine;&lt&semi;&sol;property&gt&semi; &NewLine; &NewLine;&lt&semi;property&gt&semi; &NewLine;&lt&semi;name&gt&semi;mapred&period;local&period;dir&lt&semi;&sol;name&gt&semi; &NewLine;&lt&semi;value&gt&semi;&sol;lhome&sol;hadoop&sol;data&sol;mapred&sol;local&sol;&lt&semi;&sol;value&gt&semi; &NewLine;&lt&semi;&sol;property&gt&semi; &NewLine; &NewLine;&lt&semi;&sol;configuration&gt&semi; &NewLine;<&sol;pre>&NewLine;<p>mapreduce&period;jobtracker&period;address is host or IP and port of JobTracker&period; mapreduce&period;jobtracker&period;system&period;dir is the path on the HDFS where where the Map&sol;Reduce framework stores system files&period; mapreduce&period;cluster&period;local&period;dir is comma-separated list of paths on the local filesystem where temporary MapReduce data is written&period;<&sol;p>&NewLine;<p><b>E&period; &sol;home&sol;user&sol;hadoop-1&period;2&period;1&sol;conf&sol;slaves<&sol;b><&sol;p>&NewLine;<p>Delete localhost and add all the names of the TaskTrackers&comma; each in on line&period; For example&colon;<br &sol;>&NewLine;<i>jobtrackname1<&sol;i><br &sol;>&NewLine;<i>jobtrackname2<&sol;i><br &sol;>&NewLine;<i>jobtrackname3<&sol;i><br &sol;>&NewLine;<i>jobtrackname4<&sol;i><br &sol;>&NewLine;<i>jobtrackname5<&sol;i><br &sol;>&NewLine;<i>jobtrackname6<&sol;i><&sol;p>&NewLine;<p><b>F&period; Start Hadoop<&sol;b><br &sol;>&NewLine;We need to start both the HDFS and MapReduce to start Hadoop&period;<&sol;p>&NewLine;<p><b>1&period; Format a new HDFS<&sol;b><br &sol;>&NewLine;On NameNode<br &sol;>&NewLine;<i>&dollar; hadoop namenode -format<&sol;i><br &sol;>&NewLine;Remember to delete HDFS’s local files on all nodes before re-formating it&colon;<br &sol;>&NewLine;<i>&dollar; rm &sol;home&sol;hadoop&sol;data &sol;tmp&sol;hadoop-hadoop -rf<&sol;i><&sol;p>&NewLine;<p><b>2&period; Start HDFS<&sol;b><br &sol;>&NewLine;On NameNode &colon;<&sol;p>&NewLine;<p><i>&dollar; start-dfs&period;sh<&sol;i><&sol;p>&NewLine;<p><b>3&period;Check the HDFS status&colon;<&sol;b><br &sol;>&NewLine;On NameNode &colon;<&sol;p>&NewLine;<p><i>&dollar; hadoop dfsadmin -report<&sol;i><br &sol;>&NewLine;There may be less nodes listed in the report than we actually have&period; We can try it again&period;<&sol;p>&NewLine;<p><b>4&period; Start mapred&colon;<&sol;b><br &sol;>&NewLine;On JobTracker&colon;<&sol;p>&NewLine;<p><i>&dollar; start-mapred&period;sh<&sol;i><&sol;p>&NewLine;<p><b>5&period;Check job status&colon;<&sol;b><&sol;p>&NewLine;<p><i>&dollar; hadoop job -list<&sol;i><&sol;p>&NewLine;<p><b>Shut down Hadoop cluster<&sol;b><&sol;p>&NewLine;<p>We can stop Hadoop when we no long use it&period;<&sol;p>&NewLine;<p><b>Stop HDFS on NameNode&colon;<&sol;b><&sol;p>&NewLine;<p><i>&dollar; stop-dfs&period;sh<&sol;i><&sol;p>&NewLine;<p><b>Stop JobTracker and TaskTrackers on JobTracker&colon;<&sol;b><&sol;p>&NewLine;<p><i>&dollar; stop-mapred&period;sh<&sol;i><&sol;p>&NewLine;<&sol;div>&NewLine;<div class&equals;"wp-post-navigation"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-pre"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;jobtracker-and-tasktracker-design&sol;">Previous<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-next"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;hadoop-installation-tutorial-hadoop-2x&sol;">Next<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;<script type&equals;"text&sol;javascript">&NewLine;jQuery&lpar;document&rpar;&period;ready&lpar;function&lpar;&dollar;&rpar; &lbrace;&NewLine; &dollar;&period;post&lpar;'https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-admin&sol;admin-ajax&period;php'&comma; &lbrace;action&colon; 'mts&lowbar;view&lowbar;count'&comma; id&colon; '180'&rcub;&rpar;&semi;&NewLine;&rcub;&rpar;&semi;&NewLine;<&sol;script>

Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design Patterns using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

4 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

4 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

4 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

4 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

4 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

4 years ago