This topic describes how to start the Tablestore CLI and configure information that is required to access Tablestore, such as an AccessKey pair and a Tablestore instance.
Prerequisites
If you want to use an AccessKey pair to activate Tablestore, make sure that an AccessKey pair of an Alibaba Cloud account is prepared. For more information, see Create an AccessKey pair.
If you want to use an AccessKey pair to configure a connected instance to perform operations, make sure that you have created a Resource Access Management (RAM) user, attached the AliyunOTSFullAccess policy to the RAM user, and created an AccessKey pair for the RAM user. For more information, see Create a RAM user, Grant permissions to a RAM user, and Create an AccessKey pair.
WarningIf the AccessKey pair of your Alibaba Cloud account is leaked, your resources are exposed to potential risks. We recommend that you use the AccessKey pair of a RAM user to perform operations. This prevents leakage of the AccessKey pair of your Alibaba Cloud account.
The Tablestore CLI package is downloaded. For more information, see Download the Tablestore CLI.
Procedure
Decompress the Tablestore CLI package that you downloaded. Go to the root directory of the package and select a method that is used to start the Tablestore CLI based on your operating system.
For Windows, double-click the ts.exe file.
For Linux or macOS, run the
./ts
command.NoteIf you do not have the required permissions to run the command in Linux or macOS, run the
chmod 755 ts
command to obtain the permissions and then run the command to start the Tablestore CLI.
The following information is displayed upon startup:
# Welcome to use Command Line Tool for Aliyun Tablestore. Current Version is '2021-11-11'. # _______ _ _ _ # |__ __| | | | | | | # | | __ _ | |__ | | ___ ___ | |_ ___ _ __ ___ # | | / _' || '_ \ | | / _ \ / __|| __| / _ \ | '__| / _ \ # | || (_| || |_) || || __/ \__ \| |_ | (_) || | | __/ # |_| \__,_||_.__/ |_| \___| |___/ \__| \___/ |_| \___| # # Please visit our product website: https://www.aliyun.com/product/ots # You can also join our DingTalk Chat Group (ID: 11789671 or 23307953) to discuss and ask Tablestore related questions. # tablestore>
Configure access information.
If you want to activate Tablestore or no instance is created, you need only to configure the AccessKey pair.
Example:
config --id NTS********************** --key 7NR2****************************************
If an instance is created, you can configure the instance information the same time when you configure the AccessKey pair.
Example:
config --endpoint https://myinstance.cn-hangzhou.ots.aliyuncs.com --instance myinstance --id NTS********************** --key 7NR2****************************************
If you want to access Tablestore based on temporary authorization, you can obtain temporary credential from Security Token Service (STS) and use the temporary credential to configure the access information. Example:
config --endpoint https://myinstance.cn-hangzhou.ots.aliyuncs.com --instance myinstance --id NTS********************** --key 7NR2**************************************** --token STS.6MC2****************************************
The following table describes the configuration items:
Parameter
Required
Example
Description
--endpoint
No
https://myinstance.cn-hangzhou.ots.aliyuncs.com
The endpoint of the instance. For more information, see Endpoints. This parameter is required only if you use an existing instance to configure the access information.
--instance
No
myinstance
The name of the Tablestore instance that you want to access. This parameter is required only if you use an existing instance to configure the access information.
--id
Yes
NTS**********************
The AccessKey ID and AccessKey secret of your Alibaba Cloud account or RAM user.
NoteIf you use the temporary credential obtained from STS to access Tablestore, set this parameter to the STS-returned temporary AccessKey ID and AccessKey secret.
--key
Yes
7NR2****************************************
--token
No
STS.6MC2****************************************
The temporary access token. This parameter is required if you use the temporary credential obtained from STS to access Tablestore.
References
If Tablestore is not activated, you must activate it first. For more information, see Activate Tablestore.
If no instance is created, you must create an instance and configure access information for it. For more information, see Instance operations.
If you have configured instance access information, you can use Tablestore features based on the data storage model required by your business. The following table describes the data storage models:
Data model
Use process
Wide Column model
Create a data table to store data. For more information, see Operations on data tables.
Read data from and write data to the table. For more information, see Operations on data tables.
Use indexes to accelerate data queries. For more information, see Secondary index and Search index.
Use the SQL query feature to query data. For more information, see SQL query.
If you want to migrate data or use compute engines to process data, use Tunnel Service. For more information, see Tunnel Service.
TimeSeries model
Create time series tables to store data. For more information, see Operations on a time series table.
Read data from and write data to the tables and retrieve timelines as needed. For more information, see Operations on a time series table.
Use the SQL query feature to query data. For more information, see SQL query.