简体   繁体   中英

How connect to Hortonworks sandbox Hbase using Java Client API

I have setup fresh Hortonworks sandbox .I'm trying to connect Hbase using Java Client API.This is the code i tried so far.But did not success.I did not change any configuration on Wortonworks sandbox.Do i need to do any configuration part in Hbase ?

        Configuration configuration = HBaseConfiguration.create();
        configuration.set("hbase.zookeeper.property.clientPort", "2181");
        configuration.set("hbase.zookeeper.quorum", "127.0.0.1");
        configuration.set("hbase.master", "127.0.0.1:600000");

        HBaseAdmin hBaseAdmin = new HBaseAdmin(configuration);

This happened to me too. Here's how I solved it, More details here

I did this through editing VirtualBox's Network settings. So there's no need to modify any configuration files inside the Hortonworks sandbox VM such as the /etc/hosts file or the zoo.cfg file.

In VirtualBox, for the Hortonworks Sandbox VM:

  1. Stop the VM if it's running

  2. Go to Settings -> Network, disable all current network adapters.

  3. Create a new Adapter, select Host-only Adapter , use the default settings and apply it.

  4. Start VM, ssh into it with root@192.168.56.101 (192.168.56.101 is the IP of the host-only adapter of the VM. I found it when I had two adapters enabled: NAT and host-only, ssh into the VM and run ifconfig . It seems to be the same for the same version of VM), start hbase through command line.

  5. In the machine's hosts, add

192.168.56.101 hortonworks.hbase.vm 192.168.56.101 sandbox.hortonworks.com

Java Code I use

Configuration configuration = HBaseConfiguration.create();
configuration.set("hbase.zookeeper.property.clientPort", "2181");
configuration.set("hbase.zookeeper.quorum", "hortonworks.hbase.vm");
configuration.set("zookeeper.znode.parent", "/hbase-unsecure");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM