gpt4 book ai didi

java - 尝试使用 java 连接远程服务器中的 HBase 时出现连接问题

转载 作者:可可西里 更新时间:2023-11-01 15:48:42 26 4
gpt4 key购买 nike

我尝试使用 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 >refused: no further information

我该如何解决这个问题?

最佳答案

以下异常可能有两个原因

org.apache.hadoop.hbase.MasterNotRunningException

  1. 客户端计算机无法访问远程虚拟机主机名/IP。为了解决这个问题,您需要更新入站规则以允许端口访问。如果是 VM 主机名,请确保您已在 /etc/hosts 中添加条目以使用 IP 地址解析主机名。

  2. 第二个问题可能是 HBase 主服务器正在运行。确保 HMaster 服务是否正在从您的远程服务器运行。

关于java - 尝试使用 java 连接远程服务器中的 HBase 时出现连接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53970413/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com