As with Hadoop, you first need to tell HBase where Java is located on your system. If you have the JAVA_HOME environment variable set to point to a suitable Java installation, then that will be used, and you don’t have to configure anything further. Otherwise, you can set the Java installation that HBase uses by editing HBase’s conf/hbaseenv. sh, and specifying the JAVA_HOME variable (see Appendix A for some examples) to point to version 1.6.0 of Java.

HBase, just like Hadoop, requires Java 6.For convenience, add the HBase binary directory to your command-line path. For example:

To get the list of HBase options, type:

Test Drive

To start a temporary instance of HBase that uses the /tmp directory on the local filesystem for persistence, type:

This will launch a standalone HBase instance that persists to the local filesystem; by default, HBase will write to /tmp/hbase-${USERID}. To administer your HBase instance, launch the HBase shell by typing: This will bring up a JRuby IRB interpreter that has had some HBase-specific commands added to it. Type help and then RETURN to see the list of shell commands grouped into categories. Type help COMMAND_GROUP for help by category or help COMMAND for help on a specific command and example usage. Commands use Ruby formatting to specify lists and dictionaries. See the end of the main help screen for a quick tutorial. Now let us create a simple table, add some data, and then clean up. To create a table, you must name your table and define its schema. A table’s schema comprises table attributes and the list of table column families. Column families . In standalone mode, HBase master, regionserver, and a ZooKeeper instance are all run in the same JVM.themselves have attributes that you in turn set at schema definition time. Examples ofcolumn family attributes include whether the family content should be compressed on the filesystem and how many versions of a cell to keep. Schemas can be later edited by offlining the table using the shell disable command, making the necessary alterations using alter, then putting the table back online with enable. To create a table named test with a single column family name data using defaults for table and column family attributes, enter: If the previous command does not complete successfully, and the shell displays an error and a stack trace, your install was not successful. Check the master logs under the HBase logs directory the default location forthe logs directory is${HBASE_HOME}/logs for a clue as to where things went awry.

See the help output for examples adding table and column family attributes when specifying a schema.

To prove the new table was created successfully, run the list command. This will output all tables in user space:

To insert data into three different rows and columns in the data column family, and then list the table content, do the following:

Notice how we added three new columns without changing the schema. To remove the table, you must first disable it before dropping it:

Shut down your HBase instance by running:

To learn how to set up a distributed HBase and point it at a running HDFS, see the Getting Started section of the HBase documentation.