Stay organized with collections Save and categorize content based on your preferences.

Install the HBase shell

The HBase shell is a command-line tool that performs administrative tasks, such as creating and deleting tables. The Cloud Bigtable HBase client for Java is a client library that makes it possible to use the HBase shell to connect to Bigtable.

This page describes how to install the HBase shell, along with the Cloud Bigtable HBase client for Java, on a Compute Engine instance or on your own machine. You do not need to install any other HBase dependencies, such as Apache ZooKeeper. The Cloud Bigtable HBase client for Java does not require these additional dependencies.

You can also run the HBase shell on Cloud Shell. See the Quickstart Using HBase Shell for instructions.

Before you begin

Before you begin, you'll need to complete the following tasks:

Install Java

To use the HBase shell with the Cloud Bigtable HBase client for Java, you must install a Java 8 runtime environment. Other versions of Java are not supported.

On Debian GNU/Linux or Ubuntu, you can install the Java 8 JDK by running the following commands:

sudo apt-get update
sudo apt-get install openjdk-8-jdk-headless

For other operating systems, you can download and install the Java JDK.

Install Maven

To run the HBase shell, you must install Apache Maven. The HBase shell uses Maven to download the required dependencies.

On Debian GNU/Linux or Ubuntu, you can install Maven by running the following commands:

sudo apt-get update
sudo apt-get install maven

On macOS, you can install Maven using Homebrew:

brew install maven

For other operating systems, see the instructions on the Maven website.

Obtain credentials

When you install the HBase shell on your own machine, you need to obtain user access credentials for your Google Cloud resources.

To obtain credentials, run the following command:

gcloud auth application-default login

The command opens your web browser. Choose your Google account if prompted, then click Allow to authorize access to your account.

Set up the HBase shell

Download required files

From the command line, clone the GitHub repository that contains the HBase shell quickstart:

git clone

The repository is cloned to the cloud-bigtable-examples directory.

Set the JAVA_HOME environment variable

Your shell's JAVA_HOME environment variable should be set to the location where your Java runtime environment is located.

To find the current value of JAVA_HOME:

echo ${JAVA_HOME}

If this command does not print any output, the variable is not set.

To set the value on Debian GNU/Linux or Ubuntu:

export JAVA_HOME=$(update-alternatives --list java | tail -1 | sed -E 's/\/bin\/java//')

A typical value on Debian GNU/Linux or Ubuntu is /usr/lib/jvm/java-8-openjdk-amd64/jre.

To set the value on macOS (requires Xcode's command-line tools):

export JAVA_HOME=$(/usr/libexec/java_home)

A typical value on macOS is /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home.

After you set the value of JAVA_HOME, run the following command to ensure that the value refers to the appropriate Java version:

${JAVA_HOME}/bin/java -version

Connect to a Bigtable instance

You can use the HBase shell to connect to your Bigtable instance, get information about your existing tables, and create new tables.

To start the HBase shell, run the following commands in the directory where you cloned the cloud-bigtable-examples GitHub repository:

cd quickstart

If your project has only one Bigtable instance, the HBase shell will automatically connect to that instance. If your project has multiple Bigtable instances, the HBase shell will display a list of instance IDs; type the number next to your instance ID, then press Enter.

After the HBase shell connects to your instance, it displays a series of log messages, which is normal. The shell prompt then appears:


Now that you've started the HBase shell, try running the following commands:

  • To list your tables, type list and press Enter. If you haven't created any tables yet, the HBase shell displays a message similar to the following:

    0 row(s) in 1.3580 seconds
    => []
  • To create a table, use the create command. For example, to create a table named my-table, with one column family named cf1:

    create 'my-table', 'cf1'

    The shell displays a message similar to the following:

    0 row(s) in 1.5210 seconds
    => Hbase::Table - my-table
  • To add data to a table, use the put command. For example, to put the value test-value in the row r1, using the column family cf1 and the column qualifier c1:

    put 'my-table', 'r1', 'cf1:c1', 'test-value'

    You can then use the scan command to scan the table and read the data you added:

    scan 'my-table'

    The shell displays output similar to the following:

     r1      column=cf1:c1, timestamp=1430687836046, value=test-value
    1 row(s) in 0.6260 seconds
  • To drop a table, use the disable command to disable the table, followed by the drop command. For example, to drop the table my-table:

    disable 'my-table'
    drop 'my-table'
  • To exit the HBase shell, type exit and press Enter.

While the HBase shell is running, you can type help to get usage instructions. See the HBase documentation for additional information.