Support Questions
Find answers, ask questions, and share your expertise

HBase Java client with ZooKeeper error on 2.4 sandbox

Explorer

Pretty simple Groovy client:

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.ConnectionFactory;
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.property.clientPort", "2181");
    conf.set("hbase.zookeeper.quorum", "localhost");
    conf.set("zookeeper.znode.parent", "/hbase-unsecure");
Connection conn = ConnectionFactory.createConnection(conf);
    Admin admin = conn.getAdmin()
println "${Calendar.instance.time}\tDone"

Here's the error:

2016-08-06 22:22:19 ERROR RecoverableZooKeeper:277 - ZooKeeper exists failed after 4 attempts
2016-08-06 22:22:19 ERROR RecoverableZooKeeper:277 - ZooKeeper exists failed after 4 attempts
2016-08-06 22:22:19 ERROR ZooKeeperWatcher:716 - hconnection-0x17009150x0, quorum=localhost:2181, baseZNode=/hbase-unsecure Received unexpected KeeperException, re-throwing exception
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase-unsecure/hbaseid
        at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
        at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
        at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1045)
        at org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper.exists(RecoverableZooKeeper.java:221)
        at org.apache.hadoop.hbase.zookeeper.ZKUtil.checkExists(ZKUtil.java:541)
        at org.apache.hadoop.hbase.zookeeper.ZKClusterId.readClusterIdZNode(ZKClusterId.java:65)
        at org.apache.hadoop.hbase.client.ZooKeeperRegistry.getClusterId(ZooKeeperRegistry.java:105)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.retrieveClusterId(ConnectionManager.java:880)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.<init>(ConnectionManager.java:636)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:238)
        at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:218)
        at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:119)
        at org.apache.hadoop.hbase.client.ConnectionFactory$createConnection.call(Unknown Source)

The weird part is that I can log into the VM over SSH, run "hbase shell" and do commands against HBase just fine. So clearly, it is up and running. Any suggestions?

4 REPLIES 4

Re: HBase Java client with ZooKeeper error on 2.4 sandbox

Super Collaborator

I assume VM running hbase is on the same machine as the client.

Have you checked that port 2181 is not blocked by firewall ?

Re: HBase Java client with ZooKeeper error on 2.4 sandbox

Explorer

Yeah, I thought it might be blocked, so I disabled iptables altogether. Didn't cause any change in behavior. When I run it from the Windows host, it doesn't work. If I SCP the file over to the sandbox VM, it runs just fine. I also ran zkCli.sh and couldn't even find the /hbase-unsecure/hbaseid node that it was looking for.

Re: HBase Java client with ZooKeeper error on 2.4 sandbox

Super Collaborator

Can you list what you saw under /hbase-unsecure ? Please double check hbase-site.xml to see that you're using the correct values in your Java program.

Can you inspect master / region server logs to see if there is anything interesting.

Pastebin log snippet if you need help.

Re: HBase Java client with ZooKeeper error on 2.4 sandbox

Explorer

For this error, what I did , was that I download a separate zookeeper. I start it manually. I check jps and make sure that HMaster,QuorumPeerMain, HRegionServer are there besides all others.

Then that error disappeared and I can work on HBase.