Quickstart: Query Apache HBase in Azure HDInsight with HBase Shell
In this quickstart, you learn how to use Apache HBase Shell to create an HBase table, insert data, and then query the table.
If you don't have an Azure subscription, create a free account before you begin.
Prerequisites
An Apache HBase cluster. See Create cluster to create an HDInsight cluster. Ensure you choose the HBase cluster type.
An SSH client. For more information, see Connect to HDInsight (Apache Hadoop) using SSH.
Create a table and manipulate data
For most people, data appears in the tabular format:
In HBase (an implementation of Cloud BigTable), the same data looks like:
You can use SSH to connect to HBase clusters, and then use Apache HBase Shell to create HBase tables, insert data, and query data.
Use
ssh
command to connect to your HBase cluster. Edit the command below by replacingCLUSTERNAME
with the name of your cluster, and then enter the command:ssh sshuser@CLUSTERNAME-ssh.azurehdinsight.net
Use
hbase shell
command to start the HBase interactive shell. Enter the following command in your SSH connection:hbase shell
Use
create
command to create an HBase table with two-column families. Enter the following command:create 'Contacts', 'Personal', 'Office'
Use
list
command to list all tables in HBase. Enter the following command:list
Use
put
command to insert values at a specified column in a specified row in a particular table. Enter the following command:put 'Contacts', '1000', 'Personal:Name', 'John Dole' put 'Contacts', '1000', 'Personal:Phone', '1-425-000-0001' put 'Contacts', '1000', 'Office:Phone', '1-425-000-0002' put 'Contacts', '1000', 'Office:Address', '1111 San Gabriel Dr.'
Use
scan
command to scan and return theContacts
table data. Enter the following command:scan 'Contacts'
Use
get
command to fetch contents of a row. Enter the following command:get 'Contacts', '1000'
You see similar results as using the
scan
command because there is only one row.Use
delete
command to delete a cell value in a table. Enter the following command:delete 'Contacts', '1000', 'Office:Address'
Use
disable
command to disable the table. Enter the following command:disable 'Contacts'
Use
drop
command to drop a table from HBase. Enter the following command:drop 'Contacts'
Use
exit
command to stop the HBase interactive shell. Enter the following command:exit
For more information about the HBase table schema, see Introduction to Apache HBase Schema Design. For more HBase commands, see Apache HBase reference guide.
Clean up resources
After you complete the quickstart, you may want to delete the cluster. With HDInsight, your data is stored in Azure Storage, so you can safely delete a cluster when it is not in use. You are also charged for an HDInsight cluster, even when it is not in use. Since the charges for the cluster are many times more than the charges for storage, it makes economic sense to delete clusters when they are not in use.
To delete a cluster, see Delete an HDInsight cluster using your browser, PowerShell, or the Azure CLI.
Next steps
In this quickstart, you learned how to use Apache HBase Shell to create an HBase table, insert data, and then query the table. To learn more about data stored in HBase, the next article will show you how to execute queries with Apache Spark.