我关注hbase quick start并运行了本地hbase实例。
我现在想通过java查询它,如here所示。
我现在有这个:
Configuration configuration = HBaseConfiguration.create();
HTable table1 = new HTable(configuration, "table1");
table1.close();
但是当我运行它时,过程开始,记录一堆东西,永不停止。如何从独立的Java应用程序查询本地实例?
我也试过添加它,但它没有帮助:
configuration.set("zk-quorum", "127.0.0.1");
configuration.set("zk-port", "2181");
编辑#1
看起来如果我有点耐心,我明白了:
Exception in thread "main" org.apache.hadoop.hbase.client.NoServerForRegionException: Unable to find region for table1,,99999999999999 after 10 tries.
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:936)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:841)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:943)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:845)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:810)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:232)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:172)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:131)
我没有使用这些属性:
configuration.set("hbase.zookeeper.property.clientPort", "2181");
configuration.set("hbase.zookeeper.quorum", "localhost");
configuration.set("hbase.master", "localhost:600000");
编辑#2 这是我最新的hbase-site.xml:
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///data/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/data/zookeeper</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
</configuration>
答案 0 :(得分:0)
请确保您的RegionServer正常运行。做一个快速的jps验证。此外,在本地设置设置中,不需要zk主机和端口。但使用它不会造成任何伤害。使用
configuration.set("hbase.zookeeper.property.clientPort", "2181");
configuration.set("hbase.zookeeper.quorum", "localhost");
不再需要第三个属性。
如果问题仍然存在,请告诉我您的日志文件。