{"id":6991,"date":"2013-07-17T08:26:40","date_gmt":"2013-07-17T13:26:40","guid":{"rendered":"http:\/\/bobbeaty.com\/wp\/?p=6991"},"modified":"2013-07-29T14:24:44","modified_gmt":"2013-07-29T19:24:44","slug":"installing-hadoop-on-os-x","status":"publish","type":"post","link":"https:\/\/bobbeaty.com\/wp\/archives\/6991","title":{"rendered":"Installing Hadoop on OS X"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/bobbeaty.com\/wp\/wp-content\/uploads\/2013\/07\/Hadoop.png\" alt=\"Hadoop\" title=\"Hadoop.png\" border=\"0\" width=\"130\" height=\"100\" style=\"float:right; margin-left:10px;\" \/><\/p>\n<p>This morning I <em>finally<\/em> got <a href=\"http:\/\/hadoop.apache.org\">Hadoop<\/a> installed on my work laptop, and I wanted to write it all down so that I could repeat this when necessary. As I found out, it's not <em>at all<\/em> like installing <a href=\"http:\/\/couchdb.apache.org\">CouchDB<\/a> which is about as simple as anything could be. No\u2026 Hadoop is a far more difficult beast, and I guess I can understand why, but still, it'd be nice to have a simple <a href=\"http:\/\/mxcl.github.io\/homebrew\/\">Homebrew<\/a> install that set it up in single-node mode and started everything with Launch Control, but that's a <em>wish<\/em>, not a necessity.<\/p>\n<p>So let's get into it. First, make sure that you have the SSH daemon running on your box. This is controlled in System Preferences -> Sharing -> Remote Login - make sure it's checked, save this, and it should be running just fine. Make sure you can <tt>ssh<\/tt> into your box - if necessary, make the SSH keys and put them in your <tt>~\/.ssh<\/tt> directory.<\/p>\n<p> Next, you certainly need to install <a href=\"http:\/\/mxcl.github.io\/homebrew\/\">Homebrew<\/a>, and once that's all going, you need to install the basic <a href=\"http:\/\/hadoop.apache.org\">Hadoop<\/a> package:<\/p>\n<pre class=\"bash\" style=\"font-family:monospace;\">$ brew <span style=\"color: #c20cb9; font-weight: bold;\">install<\/span> hadoop<\/pre>\n<p>at this point, you will need to edit a few of the config files, and make a few directories. Let's start by making the directories. These will be the locations for the actual Hadoop data, the Map\/Reduce data, and the NameNode data. I picked to place these next to the <a href=\"http:\/\/mxcl.github.io\/homebrew\/\">Homebrew<\/a> install of <a href=\"http:\/\/hadoop.apache.org\">Hadoop<\/a> so that it's all in one place:<\/p>\n<pre class=\"bash\" style=\"font-family:monospace;\">  $ <span style=\"color: #7a0874; font-weight: bold;\">cd<\/span> <span style=\"color: #000000; font-weight: bold;\">\/<\/span>usr<span style=\"color: #000000; font-weight: bold;\">\/<\/span>local<span style=\"color: #000000; font-weight: bold;\">\/<\/span>Cellar<span style=\"color: #000000; font-weight: bold;\">\/<\/span>hadoop\n  $ <span style=\"color: #c20cb9; font-weight: bold;\">mkdir<\/span> data\n  $ <span style=\"color: #7a0874; font-weight: bold;\">cd<\/span> data\n  $ <span style=\"color: #c20cb9; font-weight: bold;\">mkdir<\/span> dfs\n  $ <span style=\"color: #c20cb9; font-weight: bold;\">mkdir<\/span> mapred\n  $ <span style=\"color: #c20cb9; font-weight: bold;\">mkdir<\/span> nn<\/pre>\n<p>At this point we can go to the directory with the configuration files and update them:<\/p>\n<pre class=\"bash\" style=\"font-family:monospace;\">  $ <span style=\"color: #7a0874; font-weight: bold;\">cd<\/span> <span style=\"color: #000000; font-weight: bold;\">\/<\/span>usr<span style=\"color: #000000; font-weight: bold;\">\/<\/span>local<span style=\"color: #000000; font-weight: bold;\">\/<\/span>Cellar<span style=\"color: #000000; font-weight: bold;\">\/<\/span>hadoop<span style=\"color: #000000; font-weight: bold;\">\/<\/span>1.1.2<span style=\"color: #000000; font-weight: bold;\">\/<\/span>libexec<span style=\"color: #000000; font-weight: bold;\">\/<\/span>conf<\/pre>\n<p>The first update is to handle a Kerberos bug in Hadoop - a known bug. Do this by editing <tt>hadoop-env.sh<\/tt> to include:<\/p>\n<pre class=\"bash\" style=\"font-family:monospace;\">  <span style=\"color: #7a0874; font-weight: bold;\">export<\/span> <span style=\"color: #007800;\">HADOOP_OPTS<\/span>=<span style=\"color: #ff0000;\">&quot;-Djava.security.krb5.realm= -Djava.security.krb.kdc=&quot;<\/span><\/pre>\n<p>Next, edit the <tt>hdfs-site.xml<\/tt> file to include the following:<\/p>\n<pre class=\"xml\" style=\"font-family:monospace;\">  <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;configuration<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>dfs.data.dir<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\/usr\/local\/Cellar\/hadoop\/data\/dfs<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>dfs.name.dir<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\/usr\/local\/Cellar\/hadoop\/data\/nn<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>dfs.replication<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>1<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>dfs.webhdfs.enabled<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>true<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n  <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/configuration<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span><\/pre>\n<p>Next, edit the <tt>core-site.xml<\/tt> file to include the following:<\/p>\n<pre class=\"xml\" style=\"font-family:monospace;\">  <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;configuration<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>hadoop.tmp.dir<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\/tmp\/hdfs-${user.name}<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>fs.default.name<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>hdfs:\/\/localhost:9000<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;description<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>The name of the default file system.  A URI whose\n      scheme and authority determine the FileSystem implementation.  The\n      uri's scheme determines the config property (fs.SCHEME.impl) naming\n      the FileSystem implementation class.  The uri's authority is used to\n      determine the host, port, etc. for a filesystem.<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/description<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n  <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/configuration<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span><\/pre>\n<p>Finally, edit the <tt>mapred-site.xml<\/tt> file to include the following:<\/p>\n<pre class=\"xml\" style=\"font-family:monospace;\">  <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;configuration<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>mapred.job.tracker<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>localhost:9001<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;description<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>The host and port that the MapReduce job tracker runs\n      at.  If &quot;local&quot;, then jobs are run in-process as a single map\n      and reduce task.<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/description<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>mapred.local.dir<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/name<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n      <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\/usr\/local\/Cellar\/hadoop\/data\/mapred\/<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/value<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n    <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/property<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span>\n  <span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/configuration<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span><\/pre>\n<p>We are finally all configured. At this point, you need to initialize the Name node:<\/p>\n<pre class=\"bash\" style=\"font-family:monospace;\">  $ hadoop namenode <span style=\"color: #660033;\">-format<\/span><\/pre>\n<p>and then you can start all the necessary processes on the box:<\/p>\n<pre class=\"bash\" style=\"font-family:monospace;\">  $ start-all.sh<\/pre>\n<p>At this point, you will be able to hit the endpoints:<\/p>\n<ul>\n<li>NameNode: <a href=\"http:\/\/localhost:50070\">http:\/\/localhost:50070<\/a><\/li>\n<li>JobTracker: <a href=\"http:\/\/localhost:50030\">http:\/\/localhost:50030<\/a><\/li>\n<li>WebHDFS REST: <a href=\"http:\/\/localhost:50070\">http:\/\/localhost:50070<\/a><\/li>\n<\/ul>\n<p>and using the WebHDFS REST endpoint, you can use any standard REST client to submit files, delete files, make directories, and generally manipulate the filesystem as needed.<\/p>\n<p>This was interesting, and digging around for what was needed was non-trivial, but it was well worth it. I'll now be able to run my code against the PostgreSQL and Hadoop installs on my box.<\/p>\n<p>Sweet!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This morning I finally got Hadoop installed on my work laptop, and I wanted to write it all down so that I could repeat this when necessary. As I found out, it&#8217;s not at all like installing CouchDB which is about as simple as anything could be. No\u2026 Hadoop is a far more difficult beast, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,7,4],"tags":[],"class_list":["post-6991","post","type-post","status-publish","format-standard","hentry","category-clojure-coding","category-everything-else","category-open-source-software"],"_links":{"self":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/6991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/comments?post=6991"}],"version-history":[{"count":4,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/6991\/revisions"}],"predecessor-version":[{"id":6995,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/6991\/revisions\/6995"}],"wp:attachment":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/media?parent=6991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/categories?post=6991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/tags?post=6991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}