Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
140 views
in Technique[技术] by (71.8m points)

hadoop - Access virtual box hbase from windows java application

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

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>

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

MAIN PROBLEM:

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)

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

WHAT I WANT?

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

PLUS:

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

Any help would be very appreciative.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 .


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...