我正在尝试连接到安装在 ubuntu 虚拟机上的远程 hbase-0.94.8。我有一个
TableNotFoundException
,这是我的 Java 代码:
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "192.168.56.101");
HTableInterface usersTable = new HTable(config, "users");
这是完整的异常跟踪:
14/06/24 15:59:48 WARN client.HConnectionManager$HConnectionImplementation: Encountered problems when prefetch META table:
org.apache.hadoop.hbase.TableNotFoundException: Cannot find row in .META. for table: users, row=users,,99999999999999
at org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:158)
at org.apache.hadoop.hbase.client.MetaScanner.access$000(MetaScanner.java:52)
at org.apache.hadoop.hbase.client.MetaScanner$1.connect(MetaScanner.java:130)
at org.apache.hadoop.hbase.client.MetaScanner$1.connect(MetaScanner.java:127)
at org.apache.hadoop.hbase.client.HConnectionManager.execute(HConnectionManager.java:360)
at org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:127)
at org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:103)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.prefetchRegionCache(HConnectionManager.java:876)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:930)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:818)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:782)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:249)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:213)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:171)
at com.heavenize.samples.hbase.UsersTool.main(UsersTool.java:37)
Exception in thread "main" org.apache.hadoop.hbase.TableNotFoundException: users
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:952)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:818)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:782)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:249)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:213)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:171)
at com.heavenize.samples.hbase.UsersTool.main(UsersTool.java:37)
您可以在使用之前检查表。为此,您可以使用 HBaseAdmin。 创建 HBaseAdmin 实例并使用 isTableAvailable(String tableName) 方法。
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "192.168.56.101");
HBaseAdmin admin = new HBaseAdmin(config);
if(admin.isTableAvailable(tableName))
{
HTableInterface usersTable = new HTable(config, "users");
}
希望对你有帮助。