如何使用Java客户端API连接到Hortonworks沙箱Hbase [英] How connect to Hortonworks sandbox Hbase using Java Client API

查看:364
本文介绍了如何使用Java客户端API连接到Hortonworks沙箱Hbase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 配置配置= 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);


解决方案

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



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

在VirtualBox中,对于Hortonworks Sandbox VM:


  1. 停止运行虚拟机


  2. 转到设置 - >网络,禁用所有当前网络适配器。


  3. 创建一个新的适配器,选择主机专用适配器,使用默认设置并应用。


  4. 使用root@192.168.56.101启动虚拟机ssh(192.168.56.101是虚拟机主机专用适配器的IP,当我启用两个适配器时发现它:NAT和host-only,ssh进入虚拟机并运行 ifconfig ,对于相同版本的虚拟机似乎是相同的),通过命令行启动hbase。


  5. 在机器的主机中,添加



192.168.56.101 hortonworks.hbase.vm
192.168.56.101 sandbox.hortonworks.co m



我使用的Java代码

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


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 ?

        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. 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.

In VirtualBox, for the Hortonworks Sandbox VM:

  1. Stop the VM if it’s running

  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.

  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.

  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

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");

这篇关于如何使用Java客户端API连接到Hortonworks沙箱Hbase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆