繁体   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