无法将java hbase客户端连接到远程gcp kubernetes hbase服务器

egmofgnx  于 2021-05-27  发布在  Hadoop
关注(0)|答案(0)|浏览(248)

我在使用java连接到kubernetes gcp群集中的远程hbase服务器时遇到一些问题。这是我为测试连接而编写的代码。

  1. Configuration config = HBaseConfiguration.create();
  2. try {
  3. config.set("hbase.zookeeper.quorum", "34.xx.xxx.109");
  4. HBaseAdmin.checkHBaseAvailable(config);
  5. Connection connection = ConnectionFactory.createConnection(config);
  6. table = connection.getTable(TableName.valueOf("table_name"));
  7. } catch (IOException e) {
  8. e.printStackTrace();
  9. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
  10. }

但是当 HBaseAdmin.checkHBaseAvailable(config); 在引发以下异常时执行:

  1. org.apache.hadoop.hbase.MasterNotRunningException: java.net.UnknownHostException: can not resolve hbase-74fbxxx579-nglz6,16000,1603123848632
  2. at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStub(ConnectionManager.java:1625)
  3. at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$MasterServiceStubMaker.makeStub(ConnectionManager.java:1645)
  4. at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.getKeepAliveMasterService(ConnectionManager.java:1802)
  5. at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.isMasterRunning(ConnectionManager.java:994)
  6. at org.apache.hadoop.hbase.client.HBaseAdmin.checkHBaseAvailable(HBaseAdmin.java:3229)
  7. at com.arauco.modeloib.service.SensorService.testHbaseConnection(SensorService.java:68)
  8. at com.arauco.modeloib.controller.SensorController.testHbaseConnection(SensorController.java:30)
  9. at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  10. at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  11. at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  12. at java.base/java.lang.reflect.Method.invoke(Method.java:566)

我不知道可能是什么我已经编写了以下python代码,它可以工作,所以可能我缺少一些hbaseconfiguration属性,但我非常关心python与java实现之间的连接有多简单:

  1. import happybase
  2. from datetime import date
  3. connection = happybase.Connection('34.xx.xxx.109')
  4. def main():
  5. today = date.today()
  6. table = connection.table('table_name')
  7. format_today = today.strftime('%Y-%m-%d')
  8. for key, data in table.scan(row_prefix='prefix_to_search'.encode()):
  9. print(key, data)
  10. main()

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题