Lindorm Shell is an HBase client tool that connects to LindormTable using the HBase Java API. Use it to create tables, read and write data, and run DDL operations from the command line. The setup takes about 5 minutes.
Prerequisites
Before you begin, make sure you have:
Java Development Kit (JDK) 1.8 or later installed
The client machine's IP address added to your Lindorm instance whitelist. See Configure a whitelist
Usage notes
Lindorm Shell supports simple data definition language (DDL) and data read/write operations only. For unsupported operations, see Limits on HBase API.
Do not use Lindorm Shell to access wide tables created with SQL. This can cause garbled characters.
Lindorm Shell runs on Linux and macOS.
Running Lindorm Shell on Windows may cause errors or missing libraries. If this happens, add the required libraries based on the error messages.
Connect to LindormTable
Step 1: Download Lindorm Shell
Log on to the Lindorm console. In the upper-left corner, select the region where your instance is located. On the Instances page, click the target instance ID.
In the left navigation pane, click Database Connections, then click the Wide Table Engine tab.
Click Lindorm Shell Download.
Step 2: Extract the package
Run tar to extract the downloaded package. The following example extracts it to the alihbase-2.0.18 folder.
tar zxvf hbaseue-shell.tar.gzStep 3: Configure connection parameters
Open
hbase-site.xmlin thealihbase-2.0.18/confdirectory.vi alihbase-2.0.18/conf/hbase-site.xmlSet the endpoint, username, and password:
Parameter Description hbase.zookeeper.quorumThe Access By Using HBase Java API endpoint for the Wide Table Engine. Use the VPC endpoint if Lindorm Shell runs on an ECS instance in the same VPC as your Lindorm instance. Use the public endpoint if it runs on a local machine or an ECS instance in a different VPC. hbase.client.usernameThe username for LindormTable. hbase.client.passwordThe password for LindormTable. To reset a forgotten password, see Change a user password in the LindormTable Cluster Management System. <configuration> <property> <name>hbase.zookeeper.quorum</name> <value>ld-bp17j28j2y7pm****-proxy-lindorm-pub.lindorm.rds.aliyuncs.com:30020</value> </property> <property> <name>hbase.client.username</name> <value>testuser</value> </property> <property> <name>hbase.client.password</name> <value>password</value> </property> </configuration>
Step 4: Start Lindorm Shell
Run hbase shell from the alihbase-2.0.18/bin directory:
./hbase shellA successful connection shows output similar to:
Version 2.0.18, r08b8d58a9d6ce89765d5ebe2ddff425aed644c16, Mon Feb 1 12:46:39 CST 2021
Took 0.0034 secondsLindorm Shell reference
Command reference
For the full list of shell commands, see Apache HBase Shell.
Enter and exit the shell
Use hbase shell to enter the shell environment:
bin/hbase shellUse quit to exit:
quitData definition language (DDL)
| Command | Description |
|---|---|
create | Creates a table |
list | Lists all tables |
describe | Shows table properties and schema |
alter | Modifies a table |
exists | Checks whether a table exists |
disable | Disables a table (required before drop or alter) |
is_disabled | Checks whether a table is disabled |
enable | Re-enables a disabled table |
is_enabled | Checks whether a table is enabled |
drop | Deletes a disabled table |
Data manipulation language (DML)
| Command | Description |
|---|---|
put | Writes a value to a specific cell |
get | Reads a specific row or cell |
scan | Scans an entire table or a row range |
count | Returns the number of rows in a table |
delete | Deletes a specific cell |
deleteall | Deletes all cells in a row |
truncate_preserve | Deletes all table data while preserving the original region partitions |
Operation examples
Create a table and insert data
Use create to create a table. Specify the table name and at least one column family name.
create 'table_name', 'column_family_name'Example:
create 'test', 'cf'Use put to insert rows. The syntax is
put 'table', 'rowkey', 'column_family:column', 'value'.put 'test', 'row1', 'cf:a', 'value1' put 'test', 'row2', 'cf:b', 'value2' put 'test', 'row3', 'cf:c', 'value3'row1is the rowkey of thetesttable,cf:aspecifies the column family name and column name, andvalue1is the value.
Query data
Use list to list all tables. Pass an optional regular expression to filter results.
list list 'abc.*' list 'test'Use scan to read all rows in a table, or query a row range. It is slower than
getfor single-row lookups.scan 'test'Result:
ROW COLUMN+CELL row1 column=cf:a, timestamp=1421762485768, value=value1 row2 column=cf:b, timestamp=1421762491785, value=value2 row3 column=cf:c, timestamp=1421762496210, value=value3 3 row(s) in 0.0230 secondsUse get to retrieve a single row by rowkey.
get 'test', 'row1'Result:
COLUMN CELL cf:a timestamp=1421762485768, value=value1 1 row(s) in 0.0350 seconds
Disable and enable a table
Use disable before modifying or dropping a table. Use enable to restore it afterward.
disable 'table_name'
enable 'table_name'Delete a table
Use drop to delete a disabled table.
drop 'table_name'What's next
Limits on HBase API — operations not supported when connecting via HBase API
Apache HBase Shell reference — full command reference for HBase Shell