Lindorm Shell is an HBase client tool provided by Lindorm. It allows you to use HBase API for Java to connect to LindormTable and perform operations such as table creation, data inserting, and data query. This topic describes how to download Lindorm Shell and use it to connect to LindormTable.
Prerequisites
Java Development Kit (JDK) V1.8 or later is installed.
The IP address of your client is added to the whitelist of the Lindorm instance. For more information, see Configure whitelists.
Usage notes
After you use Lindorm Shell to connect to LindormTable, you can perform only simple DDL operations, data reading operations, and data writing operations. For more information, see Limits.
Do not use the HBase API to access wide tables created by using SQL.
We recommend that you deploy your client in a Linux or macOS environment when you use Lindorm Shell to connect to LindormTable.
If you deploy your client in a Windows environment, an error may be returned because of library missing. In this case, you must add the corresponding library file to your operating system.
Procedure
Download Lindorm Shell.
Log on to the Lindorm console. In the upper-left corner of the page, select the region where your Lindorm instance is deployed. On the Instances page, find the instance and click the instance ID.
In the left-side navigation pane, click Database Connections. On the page that appears, click the Wide Table Engine tab.
Click HBase Compatibility Address, and then click Download Lindorm Shell to download the package of Lindorm Shell.
Run the following command to decompress the downloaded package of Lindorm Shell to the target path. In this example, the package is decompressed to the alihbase-2.0.18 path.
tar zxvf hbaseue-shell.tar.gz
Configure connection parameters.
Go to the
alihbase-2.0.18/conf
directory and open the hbase-site.xml file.vi hbase-site.xml
Specify the endpoint, username, and password that you can to use to connect to LindormTable.
<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>
You can configure the following connection parameters in the configuration file:
hbase.zookeeper.quorum: Replace this parameter with the LindormTable endpoint that is displayed after Access by Using HBase Java API on the Wide Table Engine tab of the Lindorm console.
If Lindorm Shell is deployed on an Elastic Compute Service (ECS) instance that is located in the same VPC as your Lindorm instance, replace this parameter with the VPC endpoint of LindormTable.
If Lindorm Shell is deployed on a local computer or an ECS instance that is not located in the same region as your Lindorm instance, replace this parameter with the public endpoint of LindormTable.
hbase.client.username and hbase.client.password: Replace the two parameters individually with the username and password that you use to connect to LindormTable. If you forget the password, you can change the password in the cluster management system of LindormTable. For more information, see Change the password of a user.
Use Lindorm Shell to connect to LindormTable.
Go to the
alihbase-2.0.18/bin
path and then run the following command:./hbase shell
If the following result is returned, your client is connected to LindormTable.
Version 2.0.18, r08b8d58a9d6ce89765d5ebe2ddff425aed644c16, Mon Feb 1 12:46:39 CST 2021 Took 0.0034 seconds
NoteFor more information about the usage of Shell, see the Lindorm Shell reference section.
Lindorm Shell reference
Shell commands
For more information about the usage of Shell commands, see The Apache HBase Shell.
DDL commands
create: creates a table.
list: lists all table in Lindorm.
disable: disables a table.
is_disabled: checks whether a table is disabled.
enable: enables a table.
is_enabled: checks whether a table is enabled.
describe: describes the details of a specific table, including the attributes and schema of the table.
alter: alters the schema of a table.
exists: checks whether a table exists.
drop: deletes a table.
DML commands
put: updates the value in a specific column.
get: obtains the values in a specific row or column.
delete: deletes the value in a specific column.
deleteall: deletes all columns in a row.
scan: scans and returns data in a table.
count: counts and returns the number of columns in a table.
truncate_preserve: clear all data in a table. This operation is implemented by disabling and deleting the table and then creating a new table with the same regions as the original table.
Enter and exit Lindorm Shell
Enter Lindorm Shell.
bin/hbase shell
Exit Lindorm Shell.
quit
Examples
Create a table and insert data into the table
Creates a table. You must specify the names of the table and column family.
create 'Table name', 'Column family name'
Example:
// Create a table named test with a column family named cf. create 'test', 'cf'
Insert data to the table.
put 'Table name', 'Rowkey', 'Column family name:Column name', 'Value'
Example:
put 'test', 'row1', 'cf:a', 'value1' put 'test', 'row2', 'cf:b', 'value2' put 'test', 'row3', 'cf:c', 'value3'
NoteIn the preceding commands,
test
is the name of the table,row1
is the row key of the table,cf:a
is the column family name and column name, andvalue1
is the value of the column.
Query data
Query the information about all tables. You can use regular expressions to filter the table that you want to query.
list list 'abc.*' list 'test'
Query data in the specified table.
The
scan
command can be used to access data in HBase tables. It can also be used to flexibly query all data in a table or data within a specified range. The query speed of this command is slightly slower than theget
command. You can execute the following command to query data in the test table:scan 'Table name'
Example:
scan 'test'
The following result is returned:
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 seconds
Query a specific row of data in a table.
get 'Table name', 'Rowkey'
Example:
get 'test', 'row1'
The following result is returned:
COLUMN CELL cf:a timestamp=1421762485768, value=value1 1 row(s) in 0.0350 seconds
Enable and disable a table
You can enable or disable a specific table. Before you delete or modify the settings of a table, you must run the disable command to disable the table first. After you delete or modify the settings, you can run the enable command to enable this table.
disable 'Table name'
enable 'Table name'
Delete a table
Delete a specific table.
drop 'Table name'