我已经创建了一个示例java程序来在HBase中创建一个表,它显示成功创建了表。但是,当我打开我的HBase终端并使用命令list
时,创建的表不存在。为什么会发生这种情况?我的代码如下
Configuration config = HBaseConfiguration.create();
conf.set("hbase.master","192.168.1.47:60000");
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "192.168.1.47");
config.set("hbase.zookeeper.property.clientPort", "2181");
config.set("hbase.master", "192.168.1.47:60000");
config.set("zookeeper.znode.parent", "/hbase-unsecure");
HBaseAdmin hbase = new HBaseAdmin(conf);
HTableDescriptor desc = new HTableDescriptor("sample");
HColumnDescriptor meta = new ColumnDescriptor("samplecolumn1".getBytes());
desc.addFamily(meta);
System.out.println( "Created Success fully..." );
hbase.createTable(desc);
其中192.168.1.47:60000是Hbase所在的地方。
编辑后:
我试过现在它也给了我一个错误,
Eception in thread "main" org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: sandbox.hortonworks.com
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$StubMaker.makeStub(HConnectionManager.java:1651)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$MasterServiceStubMaker.makeStub(HConnectionManager.java:1677)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getKeepAliveMasterService(HConnectionManager.java:1884)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.listTables(HConnectionManager.java:2589)
at org.apache.hadoop.hbase.client.HBaseAdmin.listTables(HBaseAdmin.java:307)
at org.HBaseJDBC.HBaseClient.main(HBaseClient.java:53)Caused by: com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: sandbox.hortonworks.com
at org.apache.hadoop.hbase.ipc.RpcClient.callBlockingMethod(RpcClient.java:1673)
at org.apache.hadoop.hbase.ipc.RpcClient$BlockingRpcChannelImplementation.callBlockingMethod(RpcClient.java:1714)
at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$BlockingStub.isMasterRunning(MasterProtos.java:42561)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$MasterServiceStubMaker.isMasterRunning(HConnectionManager.java:1688)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$StubMaker.makeStubNoRetries(HConnectionManager.java:1597)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$StubMaker.makeStub(HConnectionManager.java:1623)
答案 0 :(得分:0)
您尚未在上述代码中创建表格,您只提供了名称和架构信息。
请在打印之前添加以下内容"完全创建成功" -
hbase.createTable(desc);