2014-09-01 116 views
2

我已经安装了新的Hortonworks沙箱。我试图使用Java客户端API连接Hbase。这是我迄今试过的代码。但没有成功。我没有更改Wortonworks沙箱上的任何配置。我是否需要在Hbase中执行任何配置部分?如何使用Java客户端API连接到Hortonworks沙箱Hbase

 Configuration configuration = HBaseConfiguration.create(); 
     configuration.set("hbase.zookeeper.property.clientPort", "2181"); 
     configuration.set("hbase.zookeeper.quorum", "127.0.0.1"); 
     configuration.set("hbase.master", "127.0.0.1:600000"); 

     HBaseAdmin hBaseAdmin = new HBaseAdmin(configuration); 
+0

默认'hbase.master.port'端口是60000,你似乎是使用600000.你可以检查端口是否匹配? – CodeRain 2015-01-02 07:11:26

回答

0

这也发生在我身上。以下是我如何解决它,更多详细信息here

我通过编辑VirtualBox的网络设置来完成此操作。因此,不需要修改Hortonworks沙箱虚拟机中的任何配置文件,例如/etc/hosts文件或zoo.cfg文件。

在VirtualBox中,对于Hortonworks沙盒VM:

  1. 停止虚拟机,如果它的运行

  2. 进入设置 - >网络,禁用所有当前的网络适配器。

  3. 创建一个新的适配器,选择Host-only Adapter,使用默认设置并应用它。 (192.168.56.101是虚拟机的主机专用适配器的IP,当我启用了两个适配器时发现它:NAT和主机专用, ssh进入虚拟机并运行ifconfig。对于相同版本的虚拟机似乎是相同的),通过命令行启动hbase。

  4. 在本机的主机,添加

192.168.56.101 hortonworks.hbase.vm 192.168.56.101 sandbox.hortonworks.com

Java代码的我用

Configuration configuration = HBaseConfiguration.create(); 
configuration.set("hbase.zookeeper.property.clientPort", "2181"); 
configuration.set("hbase.zookeeper.quorum", "hortonworks.hbase.vm"); 
configuration.set("zookeeper.znode.parent", "/hbase-unsecure");