How to connect to remote HBase in Java?

前端 未结 5 1346
独厮守ぢ
独厮守ぢ 2020-12-23 09:58

I have a standlone HBase server. This is my hbase-site.xml:


 
    hbase.rootdir
    

        
5条回答
  •  难免孤独
    2020-12-23 10:28

    In a nutshell this is what I use:

        Configuration hBaseConfig =  HBaseConfiguration.create();
        hBaseConfig.setInt("timeout", 120000);
        hBaseConfig.set("hbase.master", "*" + hbaseHost + ":9000*");
        hBaseConfig.set("hbase.zookeeper.quorum",zookeeperHost);
        hBaseConfig.set("hbase.zookeeper.property.clientPort", "2181");
    

    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.

提交回复
热议问题