Lindorm Shell is an HBase-compatible command-line tool from Lindorm. You can use it to connect to LindormTable with the HBase Java API for data operations like creating tables, inserting data, and querying data. This topic shows you how to download Lindorm Shell and connect to LindormTable.
Prerequisites
Java Development Kit (JDK) 1.8 or later is installed.
Add your client's IP address to the Lindorm instance's whitelist. For more information, see Configure a whitelist.
Usage notes
When you connect to LindormTable by using Lindorm Shell, you can perform only basic data definition language (DDL) and data manipulation language (DML) operations. For information about unsupported operations, see HBase API usage limits.
Do not use the HBase API to access wide tables created with SQL. This may return garbled characters.
We recommend using Lindorm Shell on a Linux or macOS operating system.
ImportantIf you use Lindorm Shell on Windows, you may encounter errors or missing library messages. If this happens, you must add the required library to the operating system as indicated by the error message.
Procedure
Download Lindorm Shell.
In the upper-left corner of the Lindorm console, select your instance's region. On the Instances page, click the target instance's ID.
In the left-side navigation pane, click Database Connections, and then click the Wide Table Engine tab.
Click Lindorm Shell Download.
Run the following command to decompress the Lindorm Shell package. This example decompresses the package to the
alihbase-2.0.18directory.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 connection endpoint, username, and password for 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>Parameters:
hbase.zookeeper.quorum: The connection endpoint for LindormTable. You can find this endpoint in the Access by Using HBase Java API section of the console.
VPC endpoint: Use this endpoint if Lindorm Shell is on an ECS instance in the same VPC as your Lindorm instance.
Public endpoint: Use this endpoint if Lindorm Shell is on an on-premises machine or an ECS instance outside your Lindorm instance's VPC.
hbase.client.username and hbase.client.password: The username and password used to access LindormTable. If you forget your password, you can change it in the Cluster Management System of LindormTable. For more information, see Change the password of a user.
Connect to LindormTable using Lindorm Shell.
Go to the
alihbase-2.0.18/bindirectory and run the following command../hbase shellThe following output 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 The Apache HBase Shell.
Data definition language (DDL)
create: Creates a table.
list: Lists all tables.
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: Displays a table's details, including its properties and schema.
alter: Modifies a table.
exists: Checks whether a table exists.
drop: Drops a specified table.
Data manipulation language (DML)
put: Updates the value of a specific cell.
get: Retrieves the contents 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: Truncates a table. This operation disables, deletes, and then recreates the specified table. The new table retains the same region splits as the original table.
Enter and exit shell
Enter the Shell environment.
bin/hbase shellExit the Shell environment.
quit
Examples
Create and insert data
Create a table. You must specify a name for the table and at least one 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', 'row_key', 'column_family:column_name', 'value'Example:
put 'test', 'row1', 'cf:a', 'value1' put 'test', 'row2', 'cf:b', 'value2' put 'test', 'row3', 'cf:c', 'value3'Noterow1is the row key of thetesttable,cf:aspecifies the column family and column name, andvalue1is the value.
Query data
Query information about all tables. You can use regular expressions 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 thescancommand to scan an entire table or query data within a specific range. A scan operation is slightly slower than a single-row query using thegetcommand. Run 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 secondsQuery a single row of data from a table.
get 'table_name', 'row_key'Example:
get 'test', 'row1'The following result is returned:
COLUMN CELL cf:a timestamp=1421762485768, value=value1 1 row(s) in 0.0350 seconds
Disable and enable table
Disable or enable a table. Before you can delete a table, modify its settings, or perform other management operations, you must first disable the table with the disable command. After the operation is complete, use the enable command to re-enable it.
disable 'table_name'
enable 'table_name'Drop table
Drop a specified table.
drop 'table_name'