Lindorm Shell is an HBase client tool provided by Lindorm. It uses the HBase API for Java to connect to LindormTable and perform operations, such as creating tables, inserting data, and querying data. This topic describes how to download Lindorm Shell and use it to connect to LindormTable.
Prerequisites
A Java environment is installed. Java Development Kit (JDK) 1.8 or a later version is required.
The IP address of the client is added to the whitelist of the Lindorm instance. For more information, see Configure a whitelist.
Usage notes
When you connect to LindormTable using Lindorm Shell, you can perform only simple data definition language (DDL) and data read and write operations. For more information about unsupported operations, see Limits on HBase API.
Do not use the HBase API to access wide tables created using SQL. This may cause garbled characters.
You can use Lindorm Shell on a Linux or macOS operating system.
ImportantIf you use Lindorm Shell on a Windows operating system, you may encounter errors or missing libraries. If this occurs, you must add the required libraries to your system based on the error messages.
Procedure
Download the Lindorm Shell tool.
In the upper-left corner of the Lindorm console, select the region where the instance is located. On the Instances page, click the target instance ID.
In the navigation pane on the left, click Database Connections and then click the Wide Table Engine tab.
Click Lindorm ShellDownload.
Run the command to decompress the Lindorm Shell package to a target folder. The following example shows how to decompress the package to the
alihbase-2.0.18folder.tar zxvf hbaseue-shell.tar.gzConfigure connection parameters.
Go to the
alihbase-2.0.18/confdirectory and open thehbase-site.xmlfile.vi hbase-site.xmlConfigure the endpoint, username, and password 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>Parameter descriptions:
hbase.zookeeper.quorum: The Access By Using HBase Java API endpoint for the Lindorm Wide Table Engine.
VPC endpoint: Use this endpoint if Lindorm Shell is installed on an ECS instance that is in the same VPC as the Lindorm instance.
Public endpoint: Use this endpoint if Lindorm Shell is installed on your local machine, or on an ECS instance that is not in the same VPC as the Lindorm instance.
hbase.client.username and hbase.client.password: The username and password that are used to access LindormTable. If you forget your password, you can change it in the LindormTable Cluster Management System. For more information, see Change a user password.
Access LindormTable using Lindorm Shell.
Go to the
alihbase-2.0.18/bindirectory and run the following command../hbase shellThe following information indicates a successful connection.
Version 2.0.18, r08b8d58a9d6ce89765d5ebe2ddff425aed644c16, Mon Feb 1 12:46:39 CST 2021 Took 0.0034 secondsNoteFor more information about how to use the shell, see Lindorm Shell reference.
Lindorm Shell reference
Command reference
For more information about shell commands, see Apache HBase Shell.
Data definition language
create: Creates a table.
list: Lists all tables.
disable: Disables a table.
is_disabled: Verifies whether a table is disabled.
enable: Enables a table.
is_enabled: Verifies whether a table is enabled.
describe: Displays the details of a specified table, including table properties and the table schema.
alter: Modifies a table.
exists: Verifies whether a table exists.
drop: Deletes a specified table.
Data manipulation language
put: Updates the value in a specific cell.
get: Retrieves the content of a specified row or cell.
delete: Deletes the value of a cell in a table.
deleteall: Deletes all cells in a specified row.
scan: Scans and returns table data.
count: Counts and returns the number of rows in a table.
truncate_preserve: Deletes all data in a table. This operation disables and deletes the specified table, and then re-creates it with the same region partitions as the original table.
Enter and exit the Shell environment
Enter the Shell environment.
bin/hbase shellExit the Shell environment.
quit
Operation reference
Create a table and insert data
Create a table. You must specify the names of the table and the 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.
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'Noterow1is the rowkey of thetesttable,cf:aspecifies the column family name and column name, andvalue1is the value.
Query
Query information about all tables. You can use a regular expression to filter tables.
list list 'abc.*' list 'test'Query data in a specified table.
The
scancommand provides a flexible way to access HBase data. You can use thescanoperation to scan an entire table or query data within a specific range. The query speed is slightly slower than that of querying a single piece of data using thegetcommand. Run the following statement to query the test table.scan 'table_name'Example:
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 secondsQuery a single row of data from a table.
get 'table_name', 'Rowkey'Example:
get 'test', 'row1'Result:
COLUMN CELL cf:a timestamp=1421762485768, value=value1 1 row(s) in 0.0350 seconds
Disable and enable a table
You can disable or enable a specified table. Before you delete a table, modify its settings, or perform other operations, you must first use the disable command to disable the table. After you complete the deletion or configuration changes, use the enable command to re-enable the table.
disable 'table_name'
enable 'table_name'Delete a table
Delete a specified table.
drop 'table_name'