Geeks With Blogs

News This is the *old* blog. The new one is at blog.sixeyed.com
Elton Stoneman
This is the *old* blog. The new one is at blog.sixeyed.com

image

You can run HBase in the cloud with Amazon’s Elastic MapReduce or Microsoft’s HDInsight, but for local development and testing you don’t need a full-on cluster backed by Hadoop storage, you want something leaner (and cheaper).

HBase is pretty straightforward to install and run locally, using the native filesystem so you don’t need HDFS. You can run in standalone mode (where all the services run in the same Java VM), or in pseudo-distributed mode (where you have separate Java processes for Zookeeper and the HBase Master and Region servers, but running on the same machine).

The initial installation and setup of HBase takes a few steps though (and it’s a bit fiddly on Windows, where it needs to run via the cygwin *nix environment), so a Docker image is definitely the way to go. There’s a good baseline HBase image from Nerdammer on the Docker Hub, but it doesn’t fire up the Stargate REST API for interacting with HBase. Stargate is probably the easiest cross-platform way to use HBase, and my own Docker image sixeyed/hbase-stargate extends the Nerdammer base to start Stargate when it runs.

For command-line lovers with Docker and cURL already installed, this starts HBase in a local container, and uses Stargate to  create a table called events with a single column family c; insert a row with key a|20150726|x, with value 12345 in column c:1; and then fetch that cell value back:

docker run -d -p 8080:8080 sixeyed/hbase-stargate

curl -X PUT -H Content-Type:application/json -d '{"name":"events", "ColumnSchema":[{ "name":"c"}]}' http://localhost:8080/events/schema

curl -X PUT -H Content-Type:application/json -d '{ "Row": [ { "key":"YXwyMDE1MDcyNnx4", "Cell": [ {"column":"Yzox", "$":"MTIzNDY="} ] } ] }' http://localhost:8080/events/fake-rowkey

curl -H Accept:application/json http://localhost:8080/events/a%7C20150726%7Cx

If you prefer a more guided experience, Docker’s Kitematic UI is a good option. From Kitematic, search for hbase-stargate and click Create:

image

 

That will download the image and run the container. When the container is ready, you’ll see the last line in the log telling you that Jetty (the web server for the API) is listening on port 8080:

image


With the current Kitematic build, the ports exposed from a container are mapped to random ports on your host machine, so open the Settings tab and then Ports to see where to access the API:

image

 

In this case, port 8080 in the container is mapped to 192.168.99.100:32773 on my local machine, so that’s the base URL to access the HBase REST API.

I’ve shared a Postman collection with basic Stargate requests (create table, update data, fetch row & fetch cell) here: sixeyed/hbase-stargate on getpostman. Once you’ve installed Postman and loaded the collection, create an environment where the baseUrl value is your local access URL:

image

Then you can start making requests, and check out the full HBase Stargate documentation for more options:

image

 

And be sure to keep a Base64 encoder/decoder handy. Stargate returns all data (row keys, column names and cell values) as Base64 strings.

Posted on Monday, July 27, 2015 11:06 AM HBase , Docker , Postman | Back to top

Related Posts on Geeks With Blogs Matching Categories

Comments on this post: The Easiest Way to Get Started with HBase

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Elton Stoneman | Powered by: GeeksWithBlogs.net