我正在尝试使用在 Windows 10 中运行的 Java 应用程序连接(并创建新表)到安装在 Ubuntu VM 中的 HBase。
我确信 HBase 和 java 代码都可以工作,因为如果我直接将其发送到 VM 内安装的 Intellij 中,它就可以工作,但是如果我在 Windows(主机 maquine)中启动 java 应用程序,则会返回此错误:
“线程“main”中的异常org.apache.hadoop.hbase.client.RetriesExhaustedException:尝试= 5后失败,异常: 2020-02-17T15:38:25.890Z,RpcRetryingCaller {globalStartTime = 1581953902178,pause = 100,maxAttempts = 5},org.apache.hadoop.hbase.MasterNotRunningException:java.net.ConnectException:调用danny-VirtualBox/192.168。 56.101:16000 连接异常失败:org.apache.hbase.thirdparty.io.netty.channel.AbstractChannel$AnnotatedConnectException:连接被拒绝:没有更多信息:danny-VirtualBox/192.168.56.101:16000"
我有这个代码:
public static void main(String[] args) throws Exception {
Configuration con = HBaseConfiguration.create();
con.clear();
con.set("hbase.zookeeper.quorum", "192.168.56.101");
con.set("hbase.master", "192.168.56.101:16000");
con.set("hbase.zookeeper.property.clientport", "2181");
con.set("hbase.client.retries.number", "4");
con.set("hbase.rpc.timeout", "3000");
con.set("hbase.security.authentication", "simple");
con.set("zookeeper.znode.parent", "/hbase");
Connection conn = ConnectionFactory.createConnection(con);
Admin admin = conn.getAdmin();
// Instantiating table descriptor class
HTableDescriptor tableDescriptor = new
HTableDescriptor(TableName.valueOf("emp2"));
// Adding column families to table descriptor
tableDescriptor.addFamily(new HColumnDescriptor("personal"));
tableDescriptor.addFamily(new HColumnDescriptor("professional"));
// Execute the table through admin
admin.createTable(tableDescriptor);
System.out.println(" Table created ");}
我确信主机可以“看到”虚拟机,因为我可以在 Windows 中打开 HBase Web 面板
( http://192.168.56.101:16010/master-status )
所以,我认为问题是端口或有关网络安全的问题,但我无法解决问题。你能帮我吗?
Windows机器IP:192.168.56.1 IP虚拟机:192.168.56.101
我已经使用以下值修改了 vm(hbase 机器)中的主机文件:
最佳答案
最后我解决了这个问题,您必须编辑 HBase 服务器中的主机文件来更改行:
127.0.0.1 本地主机 为了 192.168.56.101名称服务器
关于java - 使用 Java 应用程序从 Windows 10 连接 Virtualbox VM 中的 Hbase Stand Alone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60266076/