簡體   English   中英

嘗試使用Java在遠程服務器中連接HBase時出現連接問題

[英]Connection issue when trying to connect HBase in remote server using java

我嘗試使用Java與遠程服務器中的HBase連接。 下面是我的java代碼

String zookeeperHost = "myserverIP";
String tableName = "User";

Configuration hconfig = HBaseConfiguration.create();
hconfig.setInt("timeout", 1200);
hconfig.set("hbase.zookeeper.quorum",zookeeperHost);
hconfig.set("hbase.zookeeper.property.clientPort", "2181");
TableName tname = TableName.valueOf(tableName);

try {
    HBaseAdmin.checkHBaseAvailable(hconfig);
} catch (ServiceException e) {
    e.printStackTrace();
}

HTableDescriptor htable = new HTableDescriptor(tname);
htable.addFamily( new HColumnDescriptor("Id"));
htable.addFamily( new HColumnDescriptor("Name"));
System.out.println( "Connecting..." );
Connection connection = ConnectionFactory.createConnection(hconfig);
HBaseAdmin hbase_admin = (HBaseAdmin)connection.getAdmin();
System.out.println( "Creating Table..." );
hbase_admin.createTable( htable );
System.out.println("Done!");

但我不斷收到這個例外

org.apache.hadoop.hbase.MasterNotRunningException:

com.google.protobuf.ServiceException:java.net.ConnectException:連接>已拒絕:沒有更多信息

我該如何解決這個問題?

在下面的“ hconfig”中添加

 hconfig.set("hbase.master", hbaseConnectionIpAddr);
 hconfig.set("hbase.master.port", hbaseConnectionPortNum);

以下異常可能有兩個原因

org.apache.hadoop.hbase.MasterNotRunningException

  1. 客戶端計算機無法訪問遠程VM主機名/ IP。 為了解決此問題,您需要更新入站規則以允許端口訪問。 如果是VM主機名,請確保已在/etc/hosts添加了一個條目以解析具有IP地址的主機名。

  2. 第二個問題可能是HBase主服務器正在運行。 確保HMaster服務是否正在從遠程服務器運行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM