从 windows java 应用程序访问虚拟框 hbase

问题描述:

我是 hbase 的新手,正在尝试练习它.首先,我想描述一下系统配置.背景:

Hi i am new to hbase and trying to practice it. First of all i would like to describe about system configuration. BACKGROUND:

我使用的是 Windows 7 并安装了 Oracle Virtual Box.然后在 Virtual Box 上安装了 ubuntu 服务器,之后我在 ubuntu 上安装了 hbase0.98-hadoop2-bin.tar.gz.我已经在独立模式下配置了 hbase.我的 hbase-site.xml 文件是这样的:

I am using Windows 7 and installed Oracle Virtual Box. Then installed ubuntu server on Virtual Box after that I installed hbase0.98-hadoop2-bin.tar.gz on ubuntu. I have configured hbase in standalone mode. My hbase-site.xml file is like:

<Configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///home/abc/hbase</value>
</property>

<property>
<name>hbase.zookeeper.property.rootDir</name>
<value>/home/abc/zookeeper</value>
</property>
</configuration>

现在我的 hbase shell 工作正常,它创建了表.我可以放置值并获取它们.

Now my hbase shell is working fine it creates table. I can put values and get them.

主要问题:

如前所述,我使用的是 Windows,所以我在 java 中的 eclipse 上编写了一个简单的程序来访问 hbase(基本上是在虚拟机上).但我得到以下异常:

As stated I am using Windows so I wrote a simple program on eclipse in java to hit hbase (which is basically on virtual box). But I get following exception:

Exception in thread "main" org.apache.hadoop.hbase.ZooKeeperConnectionException: HBase is able to connect to ZooKeeper but the connection closes immediately. This could be a sign that the server has too many connections (30 is the default). Consider inspecting your ZK server logs for that error and then make sure you are reusing HBaseConfiguration as often as you can. See HTable's javadoc for more information.
    at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:155)
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getZooKeeperWatcher(HConnectionManager.java:990)
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.setupZookeeperTrackers(HConnectionManager.java:303)
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.<init>(HConnectionManager.java:294)
    at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:156)
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:168)
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:146)
    at HBaseConnector.main(HBaseConnector.java:151)
Caused by: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
    at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1021)
    at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1049)
    at org.apache.hadoop.hbase.zookeeper.ZKUtil.createAndFailSilent(ZKUtil.java:903)
    at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:133)

我的代码:main函数中的代码如下:

My Code: Code in main function is like:

Configuration config = HBaseConfiguration.create();
HTable table = new HTable(config, "myLittleHBaseTable");
Put p = new Put(Bytes.toBytes("myLittleRow"));

我想要什么?

我做错了什么?我有什么方法可以从 windows java 程序访问 hbase(驻留在虚拟框上)?

What am i doing wrong? I there any way to access hbase(resided on virtual box) from windows java program?

加:

我研究了之前提出的问题,但没有一个对我有用.

I studied previously asked questions but none of them was working for me.

任何帮助都会非常感激.

Any help would be very appreciative.

您是否尝试将 Virtual box 的网络设置设置为bridged Adapter"而不是NAT",然后从您的主机系统,尝试打开浏览器并输入guestIP:Hbase_Master_Port"(例如 192.168.1.100:60010)它应该打开主管理页面.

Have you tried to set the Network setting of your Virtual box to "bridged Adapter" instead of "NAT" , and then from your Host system , try to open browser and type "guestIP:Hbase_Master_Port"(192.168.1.100:60010 for example ) it should open the master administration page .