Friday, October 11, 2013

Hadoop – How to set up Hbase in eclipse


This post will guide you how to setup Hbase project in Eclipse.

Requirements:
1. Java JDK1.7.*
2. Eclipse (Eclipse IDE for Java Developers should be ok)
3. A Subversion client

Checkout HBase source code:
$ cd workplace
$ svn checkout http://svn.apache.org/repos/asf/hbase/trunk hbase

Install M2eclipse plugin:
1. From eclipse “Help”, selecy “Install New Software”
2. In the “Work with” field type : http://download.eclipse.org/technology/m2e/releases (press Enter)
3. Select m2e – Maven Integration for Eclipse

Import Hbase source code
1. Click “File” -> “Import” -> “Existing Maven Projects”


2. Generate the necessary Java resrouces. Right click on “hbase” project you just imported, choose “Run as”, then select “Maven generate-sources”, you should see the following:
[INFO] Reactor Summary:
[INFO]
[INFO] HBase ............................................. SUCCESS [0.487s]
[INFO] HBase - Common .................................... SUCCESS [4.549s]
[INFO] HBase - Protocol .................................. SUCCESS [0.001s]
[INFO] HBase - Client .................................... SUCCESS [0.001s]
[INFO] HBase - Prefix Tree ............................... SUCCESS [0.001s]
[INFO] HBase - Hadoop Compatibility ...................... SUCCESS [0.000s]
[INFO] HBase - Hadoop One Compatibility .................. SUCCESS [0.001s]
[INFO] HBase - Server .................................... SUCCESS [5.183s]
[INFO] HBase - Integration Tests ......................... SUCCESS [0.000s]
[INFO] HBase - Examples .................................. SUCCESS [0.001s]
[INFO] HBase - Assembly .................................. SUCCESS [0.000s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.854s
[INFO] Finished at: Tue Jun 04 17:06:40 EDT 2013
[INFO] Final Memory: 15M/155M
[INFO] ------------------------------------------------------------------------
3. Create run configuration
Create a new run configuration, name it ‘HBase (start)’, slect the hbase-server project and set org.apache.hadoop.hbase.master.HMaster as the main class (Right click “hbase” -> “Run as” -> “Run configurations”:



Then click on the “Run” button. You should see the following message:

...
13/06/04 17:13:36 INFO master.AssignmentManager: The master has opened the region .META.,,1.1028785192 that was online on localhost.localdomain,38890,1370380407128
13/06/04 17:13:36 INFO master.HMaster: .META. assigned=1, rit=false, location=localhost.localdomain,38890,1370380407128
13/06/04 17:13:36 INFO catalog.MetaMigrationConvertingToPB: .META. doesn't have any entries to update.
13/06/04 17:13:36 INFO catalog.MetaMigrationConvertingToPB: META already up-to date with PB serialization
13/06/04 17:13:36 INFO master.AssignmentManager: Clean cluster startup. Assigning userregions
13/06/04 17:13:36 INFO master.HMaster: Master has completed initialization

You can also try the HBase web interface http://localhost:60010.

Create a new Run configuration, set the Name to Shell, and select org.jruby.Main as the main class:


Then click on the “Run” button. You should see the following message:

HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.97.0-SNAPSHOT, r1487945, Tue Jun  4 17:06:33 EDT 2013
list
list
TABLE
0 row(s) in 1.5750 seconds




No comments: