问题
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);
回答1:
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:
Stop the VM if it’s running
Go to Settings -> Network, disable all current network adapters.
Create a new Adapter, select
Host-only Adapter, use the default settings and apply it.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.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");
来源:https://stackoverflow.com/questions/25598859/how-connect-to-hortonworks-sandbox-hbase-using-java-client-api