HBase Shell Usage

HBase Shell Usage

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 split 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.

Step 1 - Change the directory to /usr/local/hbase/bin

$ cd /usr/local/hbase/bin

Step 2 - Start all hbase daemons.

$ ./start-hbase.sh

Step 3 - The JPS (Java Virtual Machine Process Status Tool) tool is limited to reporting information on JVMs for which it has the access permissions.

$ jps

Once the HBase is up and running check the web-ui of the components as described below


Step 4 - You can start the HBase interactive shell using "hbase shell" command as shown below.

$ ./hbase shell

List is a command used to get the list of all the tables in HBase.

hbase> list

Status command returns the status of the system including the details of the servers running on the system.

hbase> status
hbase> status 'simple'
hbase> status 'summary'
hbase> status 'detailed'

Version command returns the version of HBase used in your system

hbase> version

Table Help command guides you what and how to use table-referenced commands.

hbase> table_help

Whoami command returns the user details of HBase.

hbase> whoami

Create table You can create a table using the create command, here you must specify the table name and the Column Family name.

hbase> create 'emp','personal data','professional data'

Verify the creation

hbase> list

Drop table Using the drop command, you can delete a table. Before dropping a table, you have to disable it.

hbase> disable 'emp'

hbase> drop 'emp'

drop_all This command is used to drop the tables matching the “regex” given in the command.

hbase> drop_all 'e.*'


hbase> list

Disable Table To delete a table or change its settings, you need to first disable the table using the disable command. You can re-enable it using the enable command.

hbase> disable 'emp'

Verification After disabling the table, you can still sense its existence through list and exists commands. You cannot scan it.

hbase> scan 'emp'

is_disabled This command is used to find whether a table is disabled.

hbase> is_disabled 'emp'

disable_all This command is used to disable all the tables matching the given regex.

hbase> disable_all 'e.*'

Enable Table

hbase> enable 'emp'

Verification After enabling the table, scan it. If you can see the schema, your table is successfully enabled.

hbase> scan 'emp'

is_enabled This command is used to find whether a table is enabled.

hbase> is_enabled 'emp'

enable_all This command is used to enable all the tables matching the given regex.

hbase> enable_all 'e.*'

describe This command returns the description of the table.

hbase> describe 'emp'

alter Alter is the command used to make changes to an existing table. Using this command, you can change the maximum number of cells of a column family, set and delete table scope operators, and delete a column family from a table.

hbase> alter 'emp', NAME => 'personal data', VERSIONS => 5

Table Scope Operator Using alter, you can set and remove table scope operators such as MAX_FILESIZE, READONLY, MEMSTORE_FLUSHSIZE, DEFERRED_LOG_FLUSH, etc.

hbase> alter 'emp', READONLY

Deleting a column family Using alter, you can also delete a column family. Given below is the syntax to delete a column family using alter.

hbase> alter 'emp','delete'=>'professional data'

Verification Now verify the data in the table after alteration. Observe the column family ‘professional’ is no more, since we have deleted it.

hbase> scan 'emp'

Exists You can verify the existence of a table using the exists command.

hbase> exists 'emp'

Exit from hbase shell

hbase> exit

Dont forget to stop habse daemons.

$ ./bin/stop-hbase.sh

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *