Introduction to HBase Commands
HBase Command is an Open-source Framework. It runs on the Hadoop file distributed System (HDFS) use to store sparse data sets. The key components of HBase are Zookeeper, Region, HBase Master. Hbase consists of active HBase Master server and one Region Server. Hmaster is responsible for monitoring the all-region server in a cluster. Hbase automatically partitioned into regions. Regions are stored in a file in a distributed manner. They provide random read and write operation on large datasets. They are horizontally scalable (any no. of columns can be added) and two key structures of HBase are row and column key respectively.
Basic HBase Commands (Operational Commands) are
After base Installation, interactive shell to execute commands:
Data Definition Language / Data Manipulation Commands
- Create: It creates a new table.
- Put: Inserts a new tuple into the record.
- Scan: It returns the data stored in the table.
- Get: It returns the record.
- Help: List all the commands.
base(main): 020:0> list ‘namespace name: mydb’
- Drop: To delete a specific cell in a table.
- To disable the table:
Syntax: disable ‘dataTable.’
- Updating data: To update the column, a new column value set for the same row key is created. No Update keyword is used here.
Example: Update dataTable(row key 112) to change the rating to ‘8’:
- Truncate: This command keeps the schema but not the records.
Syntax: hbase> truncate <tablename>
- Describe: Used to describe the Existing namespace.
The above output screenshot gives the following explanations:
Scanning table ‘invoice’ with attributes RAW=>true, VERSIONS=>0.
Displaying rows with column families and values in the table.
It displays random output not the same order as the values that inserted in the table
Intermediate Hbase Commands
- Create: They are used to create a table in HBase.
example: create ‘table name’, <column family>’
- disable: It is used to disable a created table.
example: Hbase> disable ‘table name’
- is_disabled: This command verifies whether a table has been disabled.
example: hbase> is disabled ‘table name.’
1. Security Commands
Below Hbase commands are used to provide the security to the database from unauthorized users.
- Grant: This command gives right permission access to read, write, execute.
example: hbase>grant< username> <permissions>[<tablename> [col name]
- Revoke: This command used to revoke user access of a table.
example:hbase> revoke<user>
- User_permissions: This command list all the access given to the table
example: hbase>user_permission ‘table name’
2. Cluster Replication Commands
They are executed when cluster set up done in Hbase to stop/add replication of clusters.
- Add peer: to add peer to clusters to replicate the data
example: hbase>add_peer ‘4’, zk4, zk5, zk6, zk7:/hbase-prod
- Start_replication: deletes all the metadata information on the peer.
example:hbase>start_replication
- Stop replication: Stops all the replication process
example:hbase>stop_replication
3. Configuring Table commands
- pme_config: This command is used to get a table’s deployment status and configuration. They write the configuration to HBase/HDFS.
- pme_dump: This command helps with debugging and troubleshooting. They output the information on the table.
- pme_set_autocompare: This command sets the autocomparerecords configuration property temporarily for the PME table.
- pme_set_autoderive: This command sets the autoderiverecords configuration property temporarily for the PME table.
- pme_set_autolink: This command sets the autolinkrecordsconfiguration property temporarily for the identified PME table.
- pme_disable_all: This command Disables all tables in HBase that are pme_enabled.
Advanced HBase commands
Let’s take a look at some of the commands which are given below:-
Hbase Namespace Commands
A namespace is a logical grouping of tables, a group of users share access to the table but with different privileges.
There are 6 namespace commands they are:
- Create_namespace: They are used to create a new namespace.
base(main): 019:0> create ‘namespace name:mydb’,’cf’
0 row(s) in 2.3760 seconds=>
Hbase:: Table – ‘namespacename:mydb
- List namespace: They list the no.of rows in the namespace.
- Load Test Tool: They test the cluster by performing read/write.
Example: Hbase: ltt -h
- wal: To get a list of Wal files.
Example: hbase wal
wal <filename> [-h] [-j] [-p] [-r]
where -h output help message
-j output Json
-p Print values
-r region to filter
- Clean: This command removes all hbase related information from HDFS.
- Alter Namespace: They alter the created namespace in HBase.
Example: base clean hbase(main): 046:0> alter_namespace ‘name2’, {METHOD => ‘set’, ‘PROERTY_NAME’ => ‘PROPERTY_VALUE’}
- Describe Namespace: They describe the existing namespace in Hbase.
Example: hbase(main):047:0> describe_namespace ‘name3’
DESCRIPTION
{NAME => ' namespace name ', PROERTY_NAME => 'PROPERTY_VALUE'}
- Hbase Snapshot:
They allow us to take a copy of a table and exporting it to another cluster. It can be stored in IBM Cloud Object storage.
Example: base org.apache.hadoop.hbase.mapreduce.Export test cos://mysql.my
- Delete a snapshot
example: hbase shell>> delete _snapshot ‘ snapshot name’
- View Snapshot info
example: hbase shell>> snapshot_info snapshot name
Tips and Tricks To use HBase commands
HBase has good random read and write access and preferred by Online analytical expertise. Representing the logical arrangements of a row in a base table is very important. Rows are stored as row keys. The row key can directly access any row. We can use HBase Shell (Command-line interface) to create an Hbase table, add rows to it, scans the complete table, and apply filters that filter row based on certain constraints. Some major factors to be considered while creating a table design. They are: Column families, rows, versions, read/write schemas. No data types are used in the base while creating a table design everything is stored as a byte array. No transactions are done in HBase. We can interact with HBase in two ways: either using Java API, HBase Shell. The capacity of the HBase cluster can be sustained by increasing the request handler thread count instantly.
Conclusion
HBase shell and general commands give appropriate information about different data manipulation types, table management, and cluster replication commands. Various functions can be performed using these commands on tables present in HBase. Hbase is integrated with Hive for SQL queries, and they do not have flexible schemas.HBase clusters are back up by full cluster shutdown, and on a live cluster, they do have automatic failover support.
Recommended Articles
This has been a guide to HBase Commands. Here we have discussed basic as well as advanced and some immediate HBase commands. You may also look at the following article to learn more –
- Important VBA Commands
- Tableau Commands
- Cheatsheet SQL (Commands, Free Tips, and Tricks)
- HBase Create Table | Syntax and Examples
20 Online Courses | 14 Hands-on Projects | 135+ Hours | Verifiable Certificate of Completion
4.5
View Course
Related Courses