English 中文(简体)
HBase - Shell
  • 时间:2024-09-17

HBase - Shell


Previous Page Next Page  

This chapter explains how to start HBase interactive shell that comes along with HBase.

HBase Shell

HBase contains a shell using which you can communicate with HBase. HBase uses the Hadoop File System to store its data. It will have a master server and region servers. The data storage will be in the form of regions (tables). These regions will be sppt up and stored in region servers.

The master server manages these region servers and all these tasks take place on HDFS. Given below are some of the commands supported by HBase Shell.

General Commands

    status - Provides the status of HBase, for example, the number of servers.

    version - Provides the version of HBase being used.

    table_help - Provides help for table-reference commands.

    whoami - Provides information about the user.

Data Definition Language

These are the commands that operate on the tables in HBase.

    create - Creates a table.

    pst - Lists all the tables in HBase.

    disable - Disables a table.

    is_disabled - Verifies whether a table is disabled.

    enable - Enables a table.

    is_enabled - Verifies whether a table is enabled.

    describe - Provides the description of a table.

    alter - Alters a table.

    exists - Verifies whether a table exists.

    drop - Drops a table from HBase.

    drop_all - Drops the tables matching the ‘regex’ given in the command.

    Java Admin API - Prior to all the above commands, Java provides an Admin API to achieve DDL functionapties through programming. Under org.apache.hadoop.hbase.cpent package, HBaseAdmin and HTableDescriptor are the two important classes in this package that provide DDL functionapties.

Data Manipulation Language

    put - Puts a cell value at a specified column in a specified row in a particular table.

    get - Fetches the contents of row or a cell.

    delete - Deletes a cell value in a table.

    deleteall - Deletes all the cells in a given row.

    scan - Scans and returns the table data.

    count - Counts and returns the number of rows in a table.

    truncate - Disables, drops, and recreates a specified table.

    Java cpent API - Prior to all the above commands, Java provides a cpent API to achieve DML functionapties, CRUD (Create Retrieve Update Delete) operations and more through programming, under org.apache.hadoop.hbase.cpent package. HTable Put and Get are the important classes in this package.

Starting HBase Shell

To access the HBase shell, you have to navigate to the HBase home folder.

cd /usr/localhost/
cd Hbase

You can start the HBase interactive shell using “hbase shell” command as shown below.

./bin/hbase shell

If you have successfully installed HBase in your system, then it gives you the HBase shell prompt as shown below.

HBase Shell; enter  help<RETURN>  for pst of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.94.23, rf42302b28aceaab773b15f234aa8718fff7eea3c, Wed Aug 27
00:54:09 UTC 2014

hbase(main):001:0>

To exit the interactive shell command at any moment, type exit or use <ctrl+c>. Check the shell functioning before proceeding further. Use the pst command for this purpose. List is a command used to get the pst of all the tables in HBase. First of all, verify the installation and the configuration of HBase in your system using this command as shown below.

hbase(main):001:0> pst

When you type this command, it gives you the following output.

hbase(main):001:0> pst
TABLE
Advertisements