title: "The node /hbase is not in ZooKeeper" when running commands in Hbase shell
body: <p>I'm trying to install HBase v1.1.2 (with Hadoop v2.7.2) in standalone mode, and am following the <a href="https://hbase.apache.org/book.html#quickstart" rel="nofollow noreferrer">Apache HBase docs</a> as closely as I can, however the configuration seems a bit tricky.   Not sure if it's related to the fact that I installed HBase with homebrew as opposed to a direct download via one of their mirror sites.  My goal is to get to the point where I can do things like create tables, list existing tables, etc.</p>
  
  <p>I have Java 1.7.0 installed, and I have run "brew install hbase" to install hbase.  In Homebrew's hbase directory, I've opened /libexec/conf/hbase-env.sh and I see the following on line 27:</p>
  
  <pre><code>export JAVA_HOME="$(/usr/libexec/java_home)"
  </code></pre>
  
  <p>When I execute <code>/usr/libexec/java_home</code> in the command line, it outputs <code>/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home</code>.  So it appears that there is a valid $JAVA_HOME env variable being set.</p>
  
  <p>In my <code>/libexec/conf/hbase-site.xml</code> configuration file, I've set the following key/value pairs:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;property&gt;
      &lt;name&gt;hbase.rootdir&lt;/name&gt;
      &lt;value&gt;file:///home/richiethomas/hbase&lt;/value&gt;
    &lt;/property&gt;
    &lt;property&gt;
      &lt;name&gt;hbase.zookeeper.property.dataDir&lt;/name&gt;
      &lt;value&gt;/home/richiethomas/zookeeper&lt;/value&gt;
    &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>In other words, I've made an exact copy of the configuration shown in the HBase docs, only replacing 'testuser' with 'richiethomas' as this is the username I'm using in my command line.</p>
  
  <p>Then in the Homebrew <code>hbase</code> directory, I run `./bin/start-hbase.sh'.  I see the following:</p>
  
  <p><code>starting master, logging to /usr/local/Cellar/hbase/1.1.2/libexec/bin/../logs/hbase-richiethomas-master-MacBook-Pro-5.local.out
  </code></p>
  
  <p>Then, I run <code>hbase shell</code> and I see the following:</p>
  
  <pre><code>SLF4J: Class path contains multiple SLF4J bindings.
  SLF4J: Found binding in [jar:file:/usr/local/Cellar/hbase/1.1.2/libexec/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: Found binding in [jar:file:/usr/local/Cellar/hadoop/2.7.2/libexec/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
  2017-01-03 17:27:52,056 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  HBase Shell; enter 'help&lt;RETURN&gt;' for list of supported commands.
  Type "exit&lt;RETURN&gt;" to leave the HBase Shell
  Version 1.1.2, rcc2b70cf03e3378800661ec5cab11eb43fafe0fc, Wed Aug 26 20:11:27 PDT 2015
  
  &gt;&gt;
  </code></pre>
  
  <p>After I do this, in a new CLI tab I <code>cat</code> the logs from the path I saw above (<code>/usr/local/Cellar/hbase/1.1.2/libexec/bin/../logs/hbase-richiethomas-master-MacBook-Pro-5.local.out</code>), and I see the following:</p>
  
  <pre><code>SLF4J: Class path contains multiple SLF4J bindings.
  SLF4J: Found binding in [jar:file:/usr/local/Cellar/hbase/1.1.2/libexec/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: Found binding in [jar:file:/usr/local/Cellar/hadoop/2.7.2/libexec/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
  </code></pre>
  
  <p>Then, back in my HBase shell, I run the following to see if everything worked, and I see the following:</p>
  
  <pre><code>&gt;&gt; list
  TABLE                                                                                                                                                                            
  2017-01-03 17:28:05,108 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
  2017-01-03 17:28:05,320 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
  2017-01-03 17:28:05,625 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
  2017-01-03 17:28:06,128 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
  2017-01-03 17:28:07,134 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
  2017-01-03 17:28:09,144 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
  2017-01-03 17:28:13,158 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
  
  ERROR: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
  
  Here is some help for this command:
  List all tables in hbase. Optional regular expression parameter could
  be used to filter the output. Examples:
  
    hbase&gt; list
    hbase&gt; list 'abc.*'
    hbase&gt; list 'ns:abc.*'
    hbase&gt; list 'ns:.*'
  </code></pre>
  
  <p>According to the Apache docs:</p>
  
  <blockquote>
    <p>You do not need to create the HBase data directory. HBase will do this
    for you. If you create the directory, HBase will attempt to do a
    migration, which is not what you want.</p>
  </blockquote>
  
  <p>I interpret this to mean that I do not need to set the following property in <code>hbase-site.xml</code>, expecially since 'hbase' is the default for 'zookeeper.znode.parent':</p>
  
  <pre><code>&lt;property&gt;
      &lt;name&gt;zookeeper.znode.parent&lt;/name&gt;
      &lt;value&gt;/hbase&lt;/value&gt;
  &lt;/property&gt;
  </code></pre>
  
  <p>The output of <code>jps</code> is the following:</p>
  
  <pre><code>32146 ZooKeeperMain
  1364 QuorumPeerMain
  83568 
  34120 Jps
  </code></pre>
  
  <p>My <code>zoo.cfg</code> file is located in <code>/usr/local/etc/zookeeper/zoo.cfg</code>, and looks like this:</p>
  
  <pre><code># The number of milliseconds of each tick
  tickTime=2000
  # The number of ticks that the initial 
  # synchronization phase can take
  initLimit=10
  # The number of ticks that can pass between 
  # sending a request and getting an acknowledgement
  syncLimit=5
  # the directory where the snapshot is stored.
  # do not use /tmp for storage, /tmp here is just 
  # example sakes.
  dataDir=/usr/local/var/run/zookeeper/data
  # the port at which the clients will connect
  clientPort=2181
  # the maximum number of client connections.
  # increase this if you need to handle more clients
  #maxClientCnxns=60
  #
  # Be sure to read the maintenance section of the 
  # administrator guide before turning on autopurge.
  #
  # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
  #
  # The number of snapshots to retain in dataDir
  #autopurge.snapRetainCount=3
  # Purge task interval in hours
  # Set to "0" to disable auto purge feature
  #autopurge.purgeInterval=1
  </code></pre>
  
  <p><strong>Solutions I've Tried:</strong></p>
  
  <p><strong>I.</strong></p>
  
  <p>I tried replacing the value of <code>zookeeper.property.dataDir</code> in the <code>hbase-site.xml</code> file with <code>/usr/local/var/run/zookeeper/data</code>, but this didn't fix the issue.</p>
  
  <p><strong>II.</strong></p>
  
  <p>When I run <code>zkcli</code> in the command line and run <code>ls /</code>, I only see <code>zookeeper</code>, no <code>hbase</code> directory.  I tried running the following command inside the zookeeper shell:</p>
  
  <p><code>create /hbase my_data</code></p>
  
  <p>I then see the following:</p>
  
  <pre><code>[zk: localhost:2181(CONNECTED) 4] ls /
  [hbase, zookeeper]
  </code></pre>
  
  <p>Then when I exit and re-run the HBase shell, and try <code>list</code>, I see the following:</p>
  
  <pre><code>&gt;&gt; list
  TABLE                                                                                                                                                                            
  
  ERROR: Can't get master address from ZooKeeper; znode data == null
  </code></pre>
  
  <p><strong>III.</strong></p>
  
  <p>According to <a href="https://www.quora.com/Which-version-of-hbase-should-I-use-with-Hadoop-2-7-1" rel="nofollow noreferrer">this Quora article</a>, HBase 1.1.2 only supports Hadoop up to versions 2.5.x, so I ran <code>brew uninstall hadoop</code> followed by <code>brew install hadoop25</code>, ran the stop and start hbase scripts, and re-launched the hbase shell.  Still no luck.</p>
  
  <p><strong>IV.</strong></p>
  
  <p>I tried uninstalling the Homebrew version and downloading HBase from an Apache mirror site, and repeating the configuration process in hbase-site.xml, but I got the same error (<code>The node /hbase is not in ZooKeeper. It should have been written by the master.</code>).</p>
  
  <p><strong>V.</strong></p>
  
  <p>I uninstalled/reinstalled HBase via Homebrew, and followed the instructions in the "Caveats" section:</p>
  
  <pre><code>==&gt; Caveats
  To have launchd start hbase now and restart at login:
    brew services start hbase
  Or, if you don't want/need a background service you can just run:
    /usr/local/opt/hbase/bin/start-hbase.sh
  </code></pre>
  
  <p>I noticed that after running the above commands, the <code>hbase-site.xml</code> file had been populated with plausible-looking values for <code>hbase.rootdir</code> and <code>hbase.zookeeper.property.dataDir</code> (specifically, <code>file:///usr/local/var/hbase</code> and <code>/usr/local/var/zookeeper</code>, respectively).  I also noticed that when I ran <code>brew services start hbase</code>, then ran <code>jps</code>, I didn't see an 'HMaster' process running, but I did see HMaster when I ran <code>/usr/local/opt/hbase/bin/start-hbase.sh</code>.  However, I then tried launching <code>hbase shell</code> and typing <code>status</code>, and I got the same error as before (<code>The node /hbase is not in ZooKeeper.</code>).</p>
  
  <p><strong>VI.</strong></p>
  
  <p>I've verified my Hadoop installation is running OK:</p>
  
  <pre><code>MacBook-Pro-5:2.5.2 richiethomas$ hadoop jar /usr/local/Cellar/hadoop25/2.5.2/libexec/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.2.jar pi 2 5
  Number of Maps  = 2
  Samples per Map = 5
  17/01/03 20:09:33 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  Wrote input for Map #0
  Wrote input for Map #1
  Starting Job
  ...
  Job Finished in 2.156 seconds
  Estimated value of Pi is 3.60000000000000000000
  </code></pre>
  
  <hr>
  
  <p>It appears there is something wrong with my HBase configuration, but I'm not sure what else to try here.</p>