I have a standlone HBase server. This is my hbase-site.xml:
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///hbase_data</value>
</property>
</configuration>
I am trying to write a Java program to manipulate the data in the HBase.
If I run the program on the HBase server, it works fine. But I don't know how to config it for remote access.
Configuration config = HBaseConfiguration.create();
HTable table = new HTable(config, "test");
Scan s = new Scan();
I have tried adding IP and Port, it doesn't work:
config.set("hbase.master", "146.169.35.28:60000")
Can anyone tell me how to do it?
Thanks!
As far as i know, If you want to connect to an remote hbase server the normal java client doesn't work,in which we just declare the configuration and try to connect to the remote hbase as mentioned in precious answers.
I have tried this above stuff but never succeeded in it. Instead i used Thrift API for connecting to a remote server,
This link is the best example of using Thrift API java client.It surely works.I am using the same. But before using it carefully go through the code and emit those items which you don't need. I am also giving the sample code for the same which successfully works.
hbase.master
is @Deprecated. Clients use Zookeeper to get current hostname/port of their HBase servers.Hadoop and HBase are very sensitive to DNS and
/etc/hosts
configuration. Make sure, your hostname doesn't point to127.0.0.1
otherwise it will start many services listening on localhost only. Try not to use IP addresses anywhere in settings.My
/etc/hosts
:/etc/hbase/hbase-site.xml
should have settingsset distributed=false
(since you are using this for testing only):/etc/zookeeper/zoo.cfg
List of my Java processes:
In my case after playing a lot with /etc/hosts I ended up finding in log file "hbase-bgi-master-servername.log" the following line:
Always make sure that the full host name ("servername.local.lan" in my case) actually points to the server's IP on both client and server side.
Here's a snippet from a system we use to create an HTable we use to connect to HBase
HTH
EDIT: Example Values:
In a nutshell this is what I use:
For hBaseHost and zookeeperHost I simply pass the ip address of a cluster computer that has zookeeper installed. Of course you can parametize the port numbers too. I am not 100% sure this is the best way to ensure a successful connection but so far it works without any issues.