{"id":55,"date":"2016-11-13T09:37:38","date_gmt":"2016-11-13T15:37:38","guid":{"rendered":"http:\/\/curiosity.roguepenguin.net\/?p=55"},"modified":"2019-05-13T06:51:27","modified_gmt":"2019-05-13T12:51:27","slug":"installing-hadoop-on-os-x-el-capitan-and-probably-sierra","status":"publish","type":"post","link":"http:\/\/curiosity.roguepenguin.net\/?p=55","title":{"rendered":"Installing Hadoop on OS X El Capitan (And probably Sierra)"},"content":{"rendered":"<p>This information is primarily sourced (read heavily copied and modified) from: <a href=\"https:\/\/getblueshift.com\/setting-up-hadoop-2-4-and-pig-0-12-on-osx-locally\/\">getblueshift.com<\/a> and references&nbsp;<a href=\"http:\/\/stackoverflow.com\/questions\/20586920\/hadoop-connecting-to-resourcemanager-failed\">stackoverflow.com<\/a>. &nbsp;This also assumes you have <a href=\"http:\/\/brew.sh\">homebrew<\/a>&nbsp;and <a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/webnotes\/install\/mac\/mac-jdk.html\">Java 1.7+<\/a> installed.<\/p>\n<p>When I did this it installed Hadoop 2.7.3<\/p>\n<p>Steps:<br \/>\n<strong>1.<\/strong> &nbsp;Set <code>JAVA_HOME<\/code>&nbsp;in your bash profile.<\/p>\n<p><code>&nbsp; $ export JAVA_HOME=$(\/usr\/libexec\/java_home)<\/code><\/p>\n<p><strong>2.<\/strong> &nbsp;Install hadoop with brew, as of this writing it will download and install 2.7.3<\/p>\n<p><code>&nbsp; $ brew install hadoop<\/code><\/p>\n<p><strong>3.<\/strong> &nbsp;To make hadoop work on a single node cluster you have to go through several steps outlined here, here are the steps in brief<\/p>\n<p><strong>4.<\/strong> &nbsp;Setup ssh to connect to localhost without login<\/p>\n<p><code>&nbsp; $ ssh-keygen -t dsa -P '' -f ~\/.ssh\/id_dsa<\/code><br \/>\n<code>&nbsp; $ cat ~\/.ssh\/id_dsa.pub &gt;&gt; ~\/.ssh\/authorized_keys<\/code><\/p>\n<p><strong>5.<\/strong> Test being able to login, if you are not able to you have to turn on Remote Login in System Preferences -&gt; Sharing<\/p>\n<p><code>&nbsp; $ ssh localhost<\/code><\/p>\n<p><strong>6.<\/strong> &nbsp;Brew installs Hadoop usually in \/usr\/local\/Cellar\/hadoop\/<\/p>\n<p><code>&nbsp; $ cd \/usr\/local\/Cellar\/hadoop\/2.7.3<\/code><\/p>\n<p><strong>Note that the version number may be different for your install<\/strong><\/p>\n<p><strong>7.<\/strong> &nbsp;Edit following config files in directory \/usr\/local\/Cellar\/hadoop\/2.7.3\/libexec\/etc\/hadoop<\/p>\n<p><code>&nbsp; $ vi hdfs-site.xml<\/code><\/p>\n<pre><code class=\"xml\"><span class=\"nt\">    &lt;configuration&gt;<\/span>\n      <span class=\"nt\">&lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;<\/span>dfs.replication<span class=\"nt\">&lt;\/name&gt;<\/span>\n        <span class=\"nt\">&lt;value&gt;<\/span>1<span class=\"nt\">&lt;\/value&gt;<\/span>\n      <span class=\"nt\">&lt;\/property&gt;<\/span>\n<span class=\"nt\">    &lt;\/configuration&gt;\n<\/span><\/code><\/pre>\n<p><code>&nbsp; $ vi core-site.xml<\/code><\/p>\n<pre><code class=\"xml\"><span class=\"nt\">    &lt;configuration&gt;<\/span>\n      <span class=\"nt\">&lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;<\/span>fs.defaultFS<span class=\"nt\">&lt;\/name&gt;<\/span>\n        <span class=\"nt\">&lt;value&gt;<\/span>hdfs:\/\/localhost:9000<span class=\"nt\">&lt;\/value&gt;<\/span>\n      <span class=\"nt\">&lt;\/property&gt;<\/span>\n<span class=\"nt\">    &lt;\/configuration&gt;<\/span><\/code><\/pre>\n<p><code>&nbsp; $ vi mapred-site.xml<\/code><\/p>\n<pre><code class=\"xml\"><span class=\"nt\">    &lt;configuration&gt;<\/span>\n      <span class=\"nt\">&lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;<\/span>mapreduce.framework.name<span class=\"nt\">&lt;\/name&gt;<\/span>\n        <span class=\"nt\">&lt;value&gt;<\/span>yarn<span class=\"nt\">&lt;\/value&gt;<\/span>\n      <span class=\"nt\">&lt;\/property&gt;<\/span>\n<span class=\"nt\">    &lt;\/configuration&gt;<\/span><\/code><\/pre>\n<p><code>&nbsp; $ vi yarn-site.xml<\/code><\/p>\n<pre><code class=\"xml\"><span class=\"nt\">    &lt;configuration&gt;<\/span>\n      <span class=\"nt\">&lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;<\/span>yarn.nodemanager.aux-services<span class=\"nt\">&lt;\/name&gt;<\/span>\n        <span class=\"nt\">&lt;value&gt;<\/span>mapreduce_shuffle<span class=\"nt\">&lt;\/value&gt;<\/span>\n      <span class=\"nt\">&lt;\/property&gt;<\/span>\n<span class=\"nt\">      &lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;<\/span>yarn.resourcemanager.address<span class=\"nt\">&lt;\/name&gt;<\/span>\n        <span class=\"nt\">&lt;value&gt;<\/span>127.0.0.1:8032<span class=\"nt\">&lt;\/value&gt;<\/span>\n      <span class=\"nt\">&lt;\/property&gt;<\/span>\n<span class=\"nt\">      &lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;<\/span>yarn.resourcemanager.scheduler.address<span class=\"nt\">&lt;\/name&gt;<\/span>\n        <span class=\"nt\">&lt;value&gt;<\/span>127.0.0.1:8030<span class=\"nt\">&lt;\/value&gt;<\/span>\n      <span class=\"nt\">&lt;\/property&gt;<\/span>\n<span class=\"nt\">      &lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;<\/span>yarn.resourcemanager.resource-tracker.address<span class=\"nt\">&lt;\/name&gt;<\/span>\n        <span class=\"nt\">&lt;value&gt;<\/span>127.0.0.1:8031<span class=\"nt\">&lt;\/value&gt;<\/span>\n      <span class=\"nt\">&lt;\/property&gt;<\/span>\n<span class=\"nt\">    &lt;\/configuration&gt;<\/span><\/code><\/pre>\n<p><strong>8.<\/strong> &nbsp;Format and start HDFS and Yarn. &nbsp;See <strong>Troubleshooting Note<\/strong> at the bottom<\/p>\n<p><code>&nbsp; $ cd \/usr\/local\/Cellar\/hadoop\/2.7.3<br \/>\n$ .\/bin\/hdfs namenode -format<br \/>\n$ .\/sbin\/start-dfs.sh<br \/>\n$ .\/bin\/hdfs dfs -mkdir \/user<br \/>\n$ .\/bin\/hdfs dfs -mkdir \/user\/&lt;username&gt;<br \/>\n$ .\/sbin\/start-yarn.sh<\/code><\/p>\n<p><strong>9.<\/strong> &nbsp;Hadoop talks to itself using two addresses, localhost and &lt;machine-name&gt;. &nbsp;Out of the box I had communication issues. &nbsp;The three address properties we added to yarn-site.xml fix one of the communication issues. &nbsp;The other will occur when MapReduce starts to run. &nbsp;It will try to connect to &lt;machine-name&gt; (Serenity in my case) but won&#8217;t be able to find it. &nbsp;To fix this issue we need to modify \/etc\/hosts<\/p>\n<p><code>&nbsp; $ sudo vi \\etc\\hosts<\/code><\/p>\n<p>The very first line will be:<br \/>\n<code>&nbsp; &nbsp; 127.0.0.1 &nbsp; &nbsp; &nbsp; localhost<\/code><br \/>\nAnd we need to change it to:<br \/>\n<code>&nbsp; &nbsp; 127.0.0.1 &nbsp; &nbsp; &nbsp; localhost Serentiy<\/code><br \/>\nThis defines both &#8220;localhost&#8221; and &#8220;Serentiy&#8221; as aliases for 127.0.0.1<\/p>\n<p><strong>10.<\/strong> &nbsp;Test examples code that came with the hadoop version<\/p>\n<p><code>&nbsp; $ .\/bin\/hdfs dfs -put libexec\/etc\/hadoop input<br \/>\n$ .\/bin\/hadoop jar libexec\/share\/hadoop\/mapreduce\/hadoop-mapreduce-examples-2.4.1.jar grep input output 'dfs[a-z.]+'<br \/>\n$ .\/bin\/hdfs dfs -get output output<br \/>\n$ cat output\/*<\/code><\/p>\n<p><strong>11.<\/strong> &nbsp;Remove tmp files<\/p>\n<p><code>&nbsp; $ .\/bin\/hdfs dfs -rmr \/users\/\/input<br \/>\n$ .\/bin\/hdfs dfs -rmr \/users\/\/ouput<br \/>\n$ rm -rf output\/<\/code><\/p>\n<p><strong>12.<\/strong>&nbsp; Stop HDFS and Yarn after you are done<\/p>\n<p><code>&nbsp; $ .\/sbin\/stop-yarn.sh<br \/>\n$ .\/sbin\/stop-dfs.sh<\/code><\/p>\n<p><strong>13.<\/strong> &nbsp;Add HADOOP_HOME and CONFIG to bashrc for future use<\/p>\n<p><code>&nbsp; $ export HADOOP_HOME=\/usr\/local\/Cellar\/hadoop\/2.7.3<br \/>\n$ export HADOOP_CONF_DIR=$HADOOP_HOME\/libexec\/etc\/hadoop<\/code><\/p>\n<p><strong>14.<\/strong> &nbsp;Complete! &nbsp;See the <a href=\"https:\/\/getblueshift.com\/setting-up-hadoop-2-4-and-pig-0-12-on-osx-locally\/\">original article<\/a> for a note about installing Pig<\/p>\n<h4>Troubleshooting Note<\/h4>\n<p><strong>Note:<\/strong>&nbsp;HDFS attempts to put the HDFS folder in<code>\/home<\/code>. &nbsp;On one of my machines this failed due to permission issues and I had to move the HDFS to a new location. &nbsp;I chose \/usr\/local\/share\/hduser\/. &nbsp;If you need to move the folder location, you will need to create the directories and the add two more properties to HDFS<\/p>\n<p><code>&nbsp; $ mkdir -p&nbsp;\/usr\/local\/share\/hduser\/mydata\/hdfs\/namenode<\/code><br \/>\n<code>&nbsp; $ mkdir -p&nbsp;\/usr\/local\/share\/hduser\/mydata\/hdfs\/datanode<\/code><br \/>\n<code>&nbsp; $ mkdir -p&nbsp;\/usr\/local\/share\/hduser\/tmp<\/code><\/p>\n<p><code>&nbsp; $ vi hdfs-site.xml<\/code><\/p>\n<pre><code class=\"xml\"><span class=\"nt\">    &lt;configuration&gt;<\/span>\n      <span class=\"nt\">&lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;<\/span>dfs.replication<span class=\"nt\">&lt;\/name&gt;<\/span>\n        <span class=\"nt\">&lt;value&gt;<\/span>1<span class=\"nt\">&lt;\/value&gt;<\/span>\n      <span class=\"nt\">&lt;\/property&gt;<\/span><\/code><code class=\"xml\"><span class=\"nt\">&lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;<\/span>dfs.namenode.name.dir<span class=\"nt\">&lt;\/name&gt;<\/span>\n        <span class=\"nt\">&lt;value&gt;file:\/usr\/local\/share\/hduser\/mydata\/hdfs\/namenode<\/span><span class=\"nt\">&lt;\/value&gt;<\/span>\n      <span class=\"nt\">&lt;\/property&gt;\n<\/span><\/code><code class=\"xml\"><span class=\"nt\">      &lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;<\/span><\/code><code class=\"xml\">dfs.datanode.name.dir<\/code><code class=\"xml\"><span class=\"nt\">&lt;\/name&gt;<\/span> \n<span class=\"nt\">        &lt;value&gt;file:\/usr\/local\/share\/hduser\/mydata\/hdfs\/datanode<\/span><span class=\"nt\">&lt;\/value&gt;\n<\/span><span class=\"nt\">      &lt;\/property&gt;\n<\/span><\/code><span class=\"nt\">    &lt;\/configuration&gt;\n\n<\/span><code>  $ vi core-site.xml<\/code><\/pre>\n<pre><code class=\"xml\"><span class=\"nt\">    &lt;configuration&gt;<\/span>\n      <span class=\"nt\">&lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;<\/span>fs.defaultFS<span class=\"nt\">&lt;\/name&gt;<\/span>\n        <span class=\"nt\">&lt;value&gt;<\/span>hdfs:\/\/localhost:9000<span class=\"nt\">&lt;\/value&gt;<\/span>\n      <span class=\"nt\">&lt;\/property&gt;\n<\/span><\/code><code class=\"xml\"><span class=\"nt\">      &lt;property&gt;<\/span>\n        <span class=\"nt\">&lt;name&gt;hadoop.tmp.dir<\/span><span class=\"nt\">&lt;\/name&gt;<\/span>\n        <span class=\"nt\">&lt;value&gt;file:\/usr\/local\/share\/hduser\/tmp<\/span><span class=\"nt\">&lt;\/value&gt;<\/span>\n      <span class=\"nt\">&lt;\/property&gt;\n<\/span><\/code><code class=\"xml\"><span class=\"nt\">    &lt;\/configuration&gt;\n<\/span><\/code><\/pre>\n<p>If you change the folder, you will need to rerun &#8220;<code>hdfs namenode -format<\/code>&#8221; to format the new location.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This information is primarily sourced (read heavily copied and modified) from: getblueshift.com and references&nbsp;stackoverflow.com. &nbsp;This also assumes you have homebrew&nbsp;and Java 1.7+ installed. When I did this it installed Hadoop 2.7.3 Steps: 1. &nbsp;Set JAVA_HOME&nbsp;in your bash profile. &nbsp; $ export JAVA_HOME=$(\/usr\/libexec\/java_home) 2. &nbsp;Install hadoop with brew, as of this writing it will download and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,6],"tags":[],"class_list":["post-55","post","type-post","status-publish","format-standard","hentry","category-hadoop","category-programming"],"_links":{"self":[{"href":"http:\/\/curiosity.roguepenguin.net\/index.php?rest_route=\/wp\/v2\/posts\/55","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/curiosity.roguepenguin.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/curiosity.roguepenguin.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/curiosity.roguepenguin.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/curiosity.roguepenguin.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=55"}],"version-history":[{"count":4,"href":"http:\/\/curiosity.roguepenguin.net\/index.php?rest_route=\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":60,"href":"http:\/\/curiosity.roguepenguin.net\/index.php?rest_route=\/wp\/v2\/posts\/55\/revisions\/60"}],"wp:attachment":[{"href":"http:\/\/curiosity.roguepenguin.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/curiosity.roguepenguin.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/curiosity.roguepenguin.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}