hbase - 如何用Java连接远程HBase?

标签 hbase

我有一个独立的 HBase 服务器。 这是我的 hbase-site.xml:

<configuration>
 <property>
    <name>hbase.rootdir</name>
    <value>file:///hbase_data</value>
  </property>
</configuration>

我正在尝试编写一个Java程序来操作HBase中的数据。

如果我在 HBase 服务器上运行该程序,它工作正常。但我不知道如何配置它以进行远程访问。

  Configuration config = HBaseConfiguration.create();
   HTable table = new HTable(config, "test");
   Scan s = new Scan();

我尝试添加IP和端口,但不起作用:

config.set("hbase.master", "146.169.35.28:60000")

谁能告诉我该怎么做?

谢谢!

最佳答案

这是我们用来创建用于连接到 HBase 的 HTable 的系统的片段

Configuration hConf = HBaseConfiguration.create(conf);
hConf.set(Constants.HBASE_CONFIGURATION_ZOOKEEPER_QUORUM, hbaseZookeeperQuorum);
hConf.setInt(Constants.HBASE_CONFIGURATION_ZOOKEEPER_CLIENTPORT, hbaseZookeeperClientPort);

HTable hTable = new HTable(hConf, tableName);

HTH

编辑:示例值:

public static final String HBASE_CONFIGURATION_ZOOKEEPER_QUORUM                     = "hbase.zookeeper.quorum";
public static final String HBASE_CONFIGURATION_ZOOKEEPER_CLIENTPORT                 = "hbase.zookeeper.property.clientPort";
...
hbaseZookeeperQuorum="PDHadoop1.corp.CompanyName.com,PDHadoop2.corp.CompanyName.com";
hbaseZookeeperClientPort=10000;
tableName="HBaseTableName";

关于hbase - 如何用Java连接远程HBase?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6614413/

相关文章:

hadoop - 带有 syslogs source 和 hbase sink 的 flum agent

filter - Hbase 0.94 中的列值范围过滤器

cygwin - 启动 Hbase : cygpath: can't convert empty path

hadoop - 通过 hive 将数据插入 hbase 时,reducer 卡在 99%

hadoop - 不能使用 'put'()通过happybase将数据添加到hbase

hadoop - HBase使用HDFS HA

apache - HBase模式设计示例

hadoop - 如何使用 MAP-REDUCE java 程序将 HBASE 表加载到 HDFS

hadoop - HBase 主状态中显示的重复区域服务器

HBase更新操作