【发布时间】:2019-05-26 23:31:54
【问题描述】:
我尝试使用 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: Connection >reused: 没有更多信息
我该如何解决这个问题?
【问题讨论】:
-
您能否检查一下 hbase 服务器是否允许您尝试连接的端口的传入连接?
-
是的,我可以从我的笔记本电脑远程登录给定端口。我的服务器是一个谷歌云虚拟机实例。我已经为 zookeeper 端口和其他所需端口创建了防火墙规则。