RSS

Using HBase with Jython

22 Apr

I started to play with HBase recently and decided to keep a log of what worked for me.
HBase version: hbase-0.90.2
Jython version: Jython 2.5.2

Steps:
1. Install Jython, HBase
2. Setting up the classpath for hbase. The commands described on the HBase wiki worked fine for me with some minor changes.

-bash-4.1$ cd hbase-0.90.2

start hbase:

-bash-4.1$ ./bin/start-hbase.sh

checkout classpath:

-bash-4.1$ ps auwx|grep java|grep org.apache.hadoop.hbase.master.HMaster|sed -r "s/.+?classpath //" | sed -r "s/ .+?//"

copy the classpath and

-bash-4.1$ export CLASSPATH=$coppied_class_path

3. Start jyphon. Since it’s quite a long line, I just made an alias for it:

-bash-4.1$ alias pyhbase='HBASE_OPTS="-Dpython.path=$JYTHON_HOME" HBASE_CLASSPATH=$JYTHON_HOME/jython.jar $HBASE_HOME/bin/hbase org.python.util.jython'

where the $JYTHON_HOME, $HBASE_HOME, as well as the $CLASSPATH and the alias can be stored in the ~/.profile file (for bash).

The jython shell appears:

-bash-4.1$ pyhbase
Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[Java HotSpot(TM) 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0_20
Type "help", "copyright", "credits" or "license" for more information.
>>>

To run a jython script:

-bash-4.1$ pyhbase jython_script

Useful links:
http://hbase.apache.org/book/quickstart.html (quick start with HBase)
http://hbase.apache.org/book/notsoquick.html (more complicated setting up for HBase)
http://wiki.apache.org/hadoop/Hbase/Jython (Using Jython to interact with HBase)

About these ads
 
1 Comment

Posted by on April 22, 2011 in working notes

 

One response to “Using HBase with Jython

  1. Gary Helmling

    April 29, 2011 at 4:17 pm

    Nice writeup! Jython makes for a great interactive shell to work with HBase.

    One tip — instead of parsing out the classpath from ps output, you can simply do:

    export CLASSPATH=`$HBASE_HOME/bin/hbase classpath`

    The “classpath” argument outputs the classpath as setup by the HBase scripts.

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: