How to connect to remote HBase in Java?

Viewed 83404

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!

5 Answers

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:

"2017-11-21 19:56:32,999 INFO [RS:0;servername:45553] regionserver.HRegionServer: Serving as servername.local.lan,45553,1511290584538, RpcServer on servername.local.lan/172.0.1.2:45553, sessionid=0x15fdff039790002"

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.

Related