HBase Shell Usage
Apache HBase is an open source, non-relational, distributed database modeled after Google's BigTable and is written in Java. It is developed as part of Apache Software Foundation's Apache Hadoop project and runs on top of HDFS (Hadoop Distributed File System), providing BigTable-like capabilities for Hadoop. That is, it provides a fault-tolerant way of storing large quantities of sparse data (small amounts of information caught within a large collection of empty or unimportant data, such as finding the 50 largest items in a group of 2 billion records, or finding the non-zero items representing less than 0.1% of a huge collection).
1) A machine with Ubuntu 14.04 LTS operating system.
2) Apache Hadoop pre installed (How to install Hadoop on Ubuntu 14.04)
3) Apache HBase pre installed (How to install HBase on Ubuntu 14.04)
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
Step 2 - Start all hbase daemons.
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.
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.
List is a command used to get the list of all the tables in HBase.
Status command returns the status of the system including the details of the servers running on the system.
Version command returns the version of HBase used in your system
Table Help command guides you what and how to use table-referenced commands.
Whoami command returns the user details of HBase.
Create table You can create a table using the create command, here you must specify the table name and the Column Family name.
Verify the creation
Drop table Using the drop command, you can delete a table. Before dropping a table, you have to disable it.
drop_all This command is used to drop the tables matching the âregexâ given in the command.
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.
Verification After disabling the table, you can still sense its existence through list and exists commands. You cannot scan it.
is_disabled This command is used to find whether a table is disabled.
disable_all This command is used to disable all the tables matching the given regex.
Verification After enabling the table, scan it. If you can see the schema, your table is successfully enabled.
is_enabled This command is used to find whether a table is enabled.
enable_all This command is used to enable all the tables matching the given regex.
describe This command returns the description of the table.
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.
Table Scope Operator Using alter, you can set and remove table scope operators such as MAX_FILESIZE, READONLY, MEMSTORE_FLUSHSIZE, DEFERRED_LOG_FLUSH, etc.
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.
Verification Now verify the data in the table after alteration. Observe the column family âprofessionalâ is no more, since we have deleted it.
Exists You can verify the existence of a table using the exists command.
Exit from hbase shell
Dont forget to stop habse daemons.
Please share this blog post and follow me for latest updates on