简体   繁体   English

如何使用Java客户端API连接到Hortonworks沙箱Hbase

[英]How connect to Hortonworks sandbox Hbase using Java Client API

I have setup fresh Hortonworks sandbox .I'm trying to connect Hbase using Java Client API.This is the code i tried so far.But did not success.I did not change any configuration on Wortonworks sandbox.Do i need to do any configuration part in Hbase ? 我已经设置了新的Hortonworks沙箱。我正在尝试使用Java客户端API连接Hbase。这是我到目前为止尝试过的代码。但是没有成功。我没有更改Wortonworks沙箱上的任何配置。我是否需要进行任何配置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);

This happened to me too. 这也发生在我身上。 Here's how I solved it, More details here 这是我的解决方法, 此处有更多详细信息

I did this through editing VirtualBox's Network settings. 我是通过编辑VirtualBox的网络设置来做到这一点的。 So there's no need to modify any configuration files inside the Hortonworks sandbox VM such as the /etc/hosts file or the zoo.cfg file. 因此,无需修改Hortonworks沙箱VM内的任何配置文件,例如/etc/hosts文件或zoo.cfg文件。

In VirtualBox, for the Hortonworks Sandbox VM: 在VirtualBox中,对于Hortonworks Sandbox VM:

  1. Stop the VM if it's running 停止VM(如果正在运行)

  2. Go to Settings -> Network, disable all current network adapters. 转到设置->网络,禁用所有当前的网络适配器。

  3. Create a new Adapter, select Host-only Adapter , use the default settings and apply it. 创建一个新的适配器,选择“ Host-only Adapter ,使用默认设置并应用它。

  4. Start VM, ssh into it with root@192.168.56.101 (192.168.56.101 is the IP of the host-only adapter of the VM. I found it when I had two adapters enabled: NAT and host-only, ssh into the VM and run ifconfig . It seems to be the same for the same version of VM), start hbase through command line. 启动VM,使用root@192.168.56.101(192.168.56.101是VM的仅主机适配器的IP)将其ssh插入其中。当启用了两个适配器(NAT和仅主机),ssh进入VM和运行ifconfig 。对于相同版本的VM似乎相同),通过命令行启动hbase。

  5. In the machine's hosts, add 在计算机的主机中,添加

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

Java Code I use 我使用的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");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM