Category Archives: BigData, NoSQL & Cloud

Big Data Analytics : What’s Next?

While a majority of Fortune 1000 companies are en-route to understanding Hadoop and adopting it in their technology stack, startups in the bay area and elsewhere have started asking the important and inevitable question: “What’s Next?”. Hadoop for the first time has allowed us to analyze massive amounts of data without necessarily indulging in expensive proprietary hardware or software. However, adoption of Hadoop alone isn’t necessarily helping businesses make smarter decisions or unearth completely new facts that could lead to immense growth of top line. The power of scalable infrastructure needs to be supplemented with nifty data mining and machine learning tools, better visualization of results, and easier ways to track and analyze the findings over a period of time. Besides, there is the entire realm of real-time analytics, which is beyond the batch oriented nature of Hadoop.

The “Global Big Data Conference“, scheduled to take place at the Santa Clara Convention Center on January 28, 2013 answers some of these very important questions around what’s happening in the field of “big data” and what’s to come next. Its a great 1 day conference that has a lot of interesting topics, covered by an awesome line-up of great speakers. In order to take advantage of some favorable pricing please register by tomorrow (January 22, 2013) and save a whole $100, as compared to the onsite price. In addition, as a reader of my blog, don’t forget to take advantage of the additional 20% discount, which you can avail by using the code: “SHAS“. See you all there!

Geolocation in MongoDB at the Silicon Valley MongoDB User Group

Thanks to all of you, who were able to join me at the session last evening. Thanks much for the kind remarks some of you left behind on the meetup message board, post the session.  Its very rewarding to know that many of you enjoyed the session and found it very useful. I loved the many questions that were brought up and discussed in the room. Please feel free to send more questions by emailing them to me at st (at) treasuryofideas (dot) com. Alternatively, you could tweet them to me at @tshanky.

The presentation from last evening is available online at

For all those who are excited about MongoDB and would like to learn more please join me for “MongoDB in an Hour!” on February 1, 2013. The format of that session would be as follows:

  • 1 hour free video session, which will be made available online by or before Feb 1, 2013.
  • 4 half-hour Google+ Hangout sessions for live Q&A.
  • Unlimited number of Q&A opportunities over email (or over a forum if we create one)
  • (optional) 1 evaluation exam. Passing the exam would entitle you to a certificate of honor.

This 1 hour session is substantially subsidized and I only ask for $25 as suggested donation to cover some of the costs.

Geolocation in MongoDB at San Francisco MonogoDB User Group

Thanks to 10gen for having me over at the last user group meetup in SF to speak on “Geolocation in MongoDB”. I have been leveraging MonogoDB’s geolocation features as a part of the super awesome, yet to be released app: doaround. I shared some of the essentials of geolocation in MongoDB during this session and plan on covering some more at the Silicon Valley MonogoDB Meetup in Palo Alto this coming January.

Thanks to all who came for my session. Thanks also for all the great questions and the conversation after the session. Here is the presentation from the session:

Build Hadoop from Source

Instructions in this write-up were tested and run successfully on Ubuntu 10.04, 10.10, 11.04, and 11.10. The instructions should run, with minor modifications, on most flavors and variants of Linux and Unix. For example, replacing apt-get with yum should get it working on Fedora and CentOS.

If you are starting out with Hadoop, one of the best ways to get it working on your box is to build it from source. Using stable binary distributions is an option, but a rather risky one. You are likely to not stop at Hadoop common but go on to setting up Pig and Hive for analyzing data and may also give HBase a try. The Hadoop suite of tools suffer from a huge version mismatch and version confusion problem. So much so that many start out with Cloudera’s distribution, also know as CDH, simply because it solves this version confusion disorder.

Michael Noll’s well written blog post titled: Building an Hadoop 0.20.x version for HBase 0.90.2, serves as a great starting point for building the Hadoop stack from source. I would recommend you read it and follow along the steps stated in that article to build and install Hadoop common. Early on in the article you are told about a critical problem that HBase faces when run on top of a stable release version of Hadoop. HBase may loose data unless it is running on top an HDFS with durable sync. This important feature is only available in the branch-0.20-append of the Hadoop source and not in any of the release versions.

Assuming you have successfully, followed along Michael’s guidelines, you should have the hadoop jars built and available in a folder named ‘build’ within the folder that contains the Hadoop source. At this stage, its advisable to configure Hadoop and take a test drive.

Configure Hadoop: Pseudo-distributed mode

Running Hadoop in pseudo-distributed mode provides a little taste of a cluster install using a single node. The Hadoop infrastructure includes a few daemon processes, namely

  1. HDFS namenode, secondary namenode, and datanode(s)
  2. MapReduce jobtracker and tasktracker(s)

When run on a single node, you can choose to run all these daemon processes within a single Java process (also known as standalone mode) or can run each daemon in a separate Java process (pseudo-distributed mode).

If you go with the pseudo-distributed setup, you will need to provide some minimal custom configuration to your Hadoop install. In Hadoop, the general philosophy is to bundle a default configuration with the source and allow for overriding it using a separate configuration file. For example, hdfs-default.xml, which you can find in the ‘src/hdfs’ folder of your Hadoop root folder, contains the default configuration for HDFS properties. The file hdfs-default.xml gets bundled within a compiled and packaged Hadoop jar file and Hadoop uses the configuration specified in this file for setting up HDFS properties. If you need to override any of the HDFS properties that uses the default configuration from hdfs-default.xml, then you need to re-specify the configuration for that property in a file named hdfs-site.xml. This custom configuration definition file, hdfs-site.xml, resides in the ‘conf’ folder within the Hadoop root folder. Custom configuration in core-site.xml, hdfs-site.xml, and mapred-site.xml corresponds to default configuration in core-default.xml, hdfs-default.xml, and mapred-default.xml, respectively.

Contents of conf/core-site.xml after custom configuration:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!-- Put site-specific property overrides in this file. -->


The specified configuration makes the HDFS namenode daemon accessible on port 9000 on localhost.

Contents of conf/hdfs-site.xml after custom configuration:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!-- Put site-specific property overrides in this file. -->

    <description>Determines where on the local filesystem the DFS name node
      should store the name table(fsimage).  If this is a comma-delimited list
      of directories then the name table is replicated in all of the
      directories, for redundancy. </description>

The override specifies a replication factor of 1. On a single node, you can’t have a failover, can over? The custom configuration also sets the namenode directory to a path on your file system. The default is a folder within your /tmp folder, which gets purged on a restart.

Contents of conf/mapred-site.xml after custom configuration:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!-- Put site-specific property overrides in this file. -->


After this configuration the MapReduce jobtracker is accessible on port 9001 on localhost.

Finally set JAVA_HOME in conf/ On my Ubuntu 11.10, I have it set as follows:

export JAVA_HOME=/usr/lib/jvm/java-6-openjdk

If you don’t have passphraseless ssh setup on your machine then you may need to execute the following commands:

ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/ >> ~/.ssh/authorized_keys

This creates a DSA encrypted key named id_dsa and adds it to the set of authorized_keys for the SSH server running on your localhost. If you aren’t sure if passphraseless ssh access is setup or not then simply run ‘ssh localhost’ on a terminal. If you are prompted for a password then you need to complete the steps to setup passphraseless ssh.

Now start up the Hadoop daemons using:


Run this command from the root of your Hadoop folder.

As an additional step set HADOOP_HOME environment variable to point to the root of your Hadoop folder. HADOOP_HOME is used by other pieces of software, like HBase, Pig, and Hive, that are built on top of Hadoop.

Running a Simple Example
If you ran the tests after the Hadoop common install and they passed, then you should be ready to use Hadoop. However, for completeness, I would suggest running a simple Hadoop example while the daemons are up and waiting. Run the simple example illustrated in the official document, available online at The example is available at the end of the sub-section on Pseudo-Distributed Operation.

Build HBase from Source

Once Hadoop is up and running, you are ready to build and run HBase. Start by getting the HBase source as follows:

git clone

I clone it from the Apache HBase mirror on Github. Alternatively, you can get the source from the HBase svn repository, which is where the official commits are checked-in.

HBase can make use of Snappy compression. Snappy is a fast compression/decompression library, which was built by Google and is available as an open source software library under the ‘New BSD License’. The official site defines snappy as follows:

Snappy is a compression/decompression library. It does not aim for maximum compression, or compatibility with any other compression library; instead, it aims for very high speeds and reasonable compression. For instance, compared to the fastest mode of zlib, Snappy is an order of magnitude faster for most inputs, but the resulting compressed files are anywhere from 20% to 100% bigger. On a single core of a Core i7 processor in 64-bit mode, Snappy compresses at about 250 MB/sec or more and decompresses at about 500 MB/sec or more.

Snappy is widely used inside Google, in everything from BigTable and MapReduce to our internal RPC systems. (Snappy has previously been referred to as “Zippy” in some presentations and the likes.)

You can learn more about Snappy at

To build HBase with snappy support we need to do the following:

  1. Build and install the snappy library
  2. Build and install hadoop-snappy, the library that bridges snappy and Hadoop
  3. Compile HBase with snappy

Build and Install snappy
Building and installing snappy is easy and quick. Get the latest stable snappy release as follows:


The current latest release version is 1.0.4. This version number could vary as newer versions supersede this version.
Once you download the snappy zipped tarball, extract it:

tar zxvf snappy-1.0.4.tar.gz

Next, change into the snappy extracted folder and use the common configure, make, make install trio to complete the build and install process.

cd snappy-1.0.4
./configure && make && sudo make install

You may need to run ‘make install’ using the privileges of a superuser, i.e. ‘sudo make install’.

Build and Install hadoop-snappy
Hadoop-snappy is a project for Hadoop that provides access to the snappy compression/decompression library. You can learn details about hadoop-snappy at Building and installing haddop-snappy requires Maven. To get started checkout the hadoop-snappy code from its subversion repository like so:

svn checkout hadoop-snappy-read-only

Then, change to the ‘hadoop-snappy-read-only’ folder and make a small modification to maven/build-compilenative.xml :

# add JAVA_HOME as an env var
<exec dir="${native.staging.dir}" executable="sh" failonerror="true">
    <env key="OS_NAME" value="${}"/>
    <env key="OS_ARCH" value="${os.arch}"/>
    <env key="JVM_DATA_MODEL" value="${}"/>
    <env key="JAVA_HOME" value="/usr/lib/jvm/java-6-openjdk"/>
    <arg line="configure ${native.configure.options}"/>

Also, install a few required zlibc related libraries:

sudo apt-get install zlibc zlib1g zlib1g-dev[/pre]
Next, build Hadoop-snappy using maven like so:
1sudo mvn package

Once hadoop-snappy is built, install the jar and tar distributions of hadoop-snappy to your local repository:

mvn install:install-file -DgroupId=org.apache.hadoop -DartifactId=hadoop-snappy -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar -Dfile=./target/hadoop-snappy-0.0.1-SNAPSHOT.jar
mvn install:install-file -DgroupId=org.apache.hadoop -DartifactId=hadoop-snappy -Dversion=0.0.1-SNAPSHOT -Dclassifier=Linux-amd64-64 -Dpackaging=tar -Dfile=./target/hadoop-snappy-0.0.1-SNAPSHOT-Linux-amd64-64.tar 

Compile, Configure & Run HBase
Once snappy and hadoop-snappy are compiled and installed, you are ready to compile HBase with snappy support. Change to the folder that contains the HBase repository clone and run the ‘maven compile’ command to build HBase from source.

cd hbase
mvn compile -Dsnappy

The -Dsnappy option tells maven to compile HBase with snappy support.

Earlier, I setup Hadoop to run in pseudo-distributed mode. Lets configure HBase to also run in pseudo-distributed mode. Alike Hadoop, the default configuration for HBase is available in hbase-default.xml and custom configuration can be specified to override the default configuration. Custom configuration resides in conf/hbase-site.xml. To setup, HBase in pseudo-distributed make sure the contents of conf/hbase-site.xml are as follows:

        <description>The directory shared by RegionServers.
        <description>The replication count for HLog and HFile storage.
        Should not be greater than HDFS datanode count.

You may recall we configured the HDFS namenode to be accessible on port 9000 on localhost. Therefore, the ‘hbase.rootdir’ needs to be specified with respect to the HDFS url. If you configure to run HDFS daemons on a different port, then please adjust the configuration for ‘hbase.rootdir’ in line with that. The second custom property definition sets replication factor value to 1. On a single node thats the best and only option you have!

Now you can start-up Hbase using:


Build Pig
Building and Installing Pig from source is a simple 3 command operation like so:

svn checkout pig
cd pig

The first command checks out source from the Pig svn repository. It grabs the source from the ‘trunk’, which is referred to as ‘master’ in git jargon. The second command changes to the folder that contains the pig source. The third command compiles the pig source using Apache Ant. Invoking the default target, i.e. simply calling ‘ant’ without any argument, compiles Pig and packages it as a jar for distribution and consumption. Pig jar file can be found at the root of the Pig folder. Pig usually generates two jar files:

  1. pig.jar — to be run with Hadoop.
  2. pigwithouthadoop.jar — to be run locally. Pig does not need to always use Hadoop.

Build Hive
Building and Installing Hive is almost as easy as building and installing Pig. The following set of commands gets the job done:

svn co hive
cd hive
ant package

You should be able to understand the commands if you have come so far in this article.

There is one little catch in this Hive instruction set though. As you run the ‘ant package’ task you will see the build fail. With HADOOP_HOME pointing to a hadoop-0.20-append branch build, Hive ShimLoader does not get the Hadoop version correctly. Its the “-” in the name that causes the problem! Apply, the simple patch available at and things should work just fine. Apply the patch as follows:

patch -p0 -i HIVE-2294.3.patch

To start using Hive, you will also need to minimally carry out these additional tasks:

  • Set HIVE_HOME environment variable to point to the root of the HIVE directory.
  • Add $HIVE_HOME/bin to $PATH
  • Create /tmp in HDFS and set appropriate permissions
bin/hadoop fs -mkdir /tmp 
bin/hadoop fs -chmod g+w   /tmp
  • Create /user/hive/warehouse and set appropriate permissions
bin/hadoop fs -mkdir /user/hive/warehouse 
bin/hadoop fs -chmod g+w /user/hive/warehouse

Now you are ready with pseduo-distributed Hadoop, pseudo-distributed HBase, Pig, and Hive running on your box. This is of course just the beginning. You need to learn to leverage these tools to analyze data, but that not covered in this write-up. A following post will possibly address the topic of analyzing data using MapReduce and its abstractions.

My new book: Professional NoSQL (Wiley, 2011)

My new book, Professional NoSQL (Wiley, 2011) is now available in bookstores.

NoSQL is an emerging topic and a lot of developers, architects, technology managers, and CIO(s) are fairly confused trying to understand where it fits in the stack. While these folks are trying to come up to speed and climb up the learning curve, many NoSQL enthusiasts and product vendors are presenting the usual jargon heavy, myth centric promises and confusing them further. Given this context, I have made an attempt to present an unbiased and objective overview of the topic: explaining the fundamentals, introducing the products, presenting a few of its nuances, and describing the context in which it exists.

Read the first chapter, which is available for download online and consider buying a copy. If you find errors, then please let me know of them.

Hope you enjoy reading the book and find it useful.

Research Papers and Videos on Google Bigtable, GFS, Chubby and MapReduce

Thanks all for coming to my talk today on sorted ordered column-family stores at the Silicon Valley Cloud Computing Meetup. Here are the links to the Google’s research papers and a couple of videos that relate to Bigtable (and Google App Engine internals):

Bigtable: A Distributed Storage System for Structured Data

The Chubby Lock Service for Loosely-Coupled Distributed Systems

The Google File System

MapReduce: Simplified Data Processing on Large Clusters

BigTable: A Distributed Structured Storage System –

Google I/O 2008 – App Engine Datastore Under the Covers –

Enjoy reading the research papers and watching the videos!

Getting Friendly With Document Databases

Here is a draft of what I plan to present in Part 1 of the NoSQL Series on Jan 24th at Fenwick & West in Mountain View, CA (The series has 4 parts in all. It runs between 1/24 and 1/27, everyday at 7pm). The event is  hosted by the Silicon Valley Cloud Computing Meetup.

Topic: Getting Friendly With Document Databases

Products covered: MongoDB ( and CouchDB (
Level: Introductory but not cursory. Full of examples.
Duration: 60 mins. (1 hour) — may have too much for an hour. Could do a bit more than an hour if need be.
Session Contents:
– Document databases
  • What are they?
  • Their essential structure (in the context of MongoDB and CouchDB)
  • Data types supported
  • Schemaless
– Creating, Reading, Updating and Deleting Documents
  • Using MongoDB
  • Using CouchDB
– Querying Documents
  • Filtering
  • Ordering
  • Limiting result set
  • Grouping
  • Joining (?)
(Includes MapReduce)
– Indexes
  • Types
  • How-to
– Very first steps in performance tuning
  • Understanding query plans
  • Faster query results
– A few peculiarities
– Questions
This should give you a head start but an hour isn’t enough to cover all the details so am planning on organizing a follow-up 2 day training in February. See you on Jan 24 at Fenwick & West.

NoSQL Sessions at Silicon Valley Cloud Computing Meetup in January 2011

After Santa Claus has come and gone, NoSQL is coming to town! Come January 2011, I present the core NoSQL ideas, concepts, tools and technologies via a set of 4 day back-to-back sessions at the Silicon Valley Cloud Computing Meetup. The schedule is as follows:

Jan 24th (Monday): NoSQL Series – Part 1: Getting friendly with document databases
Jan 25th (Tuesday): NoSQL Series – Part 2: Nothing beats a distributed hash
Jan 26th (Wednesday): NoSQL Series – Part 3: HBase beyond the “Hello World!”
Jan 27th (Thursday): NoSQL Series – Part 4: Eventually it’s consistent
The venue is:
Fenwick & West
801 California St
Mountain View, CA 94041

Each day session starts at 7pm so you don’t have to miss work to join us for these sessions. Actually, wanted to make sure everyone was tired after a long day’s work so there were less questions :)

Each session is about an hour and a half long with a short break of 5 mins. or so in the middle. There is pizza, veggies and desserts to go along with the talk.

Thanks to Sebastian Stadil for organizing the Silicon Valley Cloud Computing Meetup and making these sessions possible. If you are into big data, cloud computing and web scale stuff and are in the bay area then this meetup is surely the one you should join.

All these talks will leverage my efforts towards writing Wiley’s Professional NoSQL (coming end of Q1/Q2 2011).