Use the Tablestore CLI to manage wide-column and time-series data for development, debugging, and operations.
Quick start
Download the CLI tool and configure access credentials to start managing Tablestore resources.
Download the CLI tool
The CLI tool supports Windows, Linux, and macOS.
|
Platform |
Download link |
|
Windows |
|
|
Linux |
|
|
macOS |
Start the CLI tool and configure credentials
Extract the package and start the CLI tool from the extracted directory.
Windows
Double-click the ts.exe file.
Linux and macOS
Run the ./ts command.
If the file does not have execute permission on Linux or macOS, run
chmod 755 tsto grant the permission before you start the tool.If macOS displays the message
"ts" cannot be opened because Apple cannot check it for malicious software, go to Privacy & Security settings to allowtsto run.
After the CLI tool starts, run the config command to configure access credentials:
config --endpoint https://myinstance.cn-hangzhou.ots.aliyuncs.com --instance myinstance --id LTAI******************** --key 7NR2****************************************
|
Parameter |
Description |
|
|
The endpoint URL of the instance. |
|
|
The instance name. |
|
|
The AccessKey ID. For more information, see Create an AccessKey. |
|
|
The AccessKey Secret. |
|
|
(Optional) The STS token. Specify this parameter to access Tablestore with temporary access credentials. |
To access Tablestore with STS temporary access, add the --token parameter to the config command:
config --endpoint https://myinstance.cn-hangzhou.ots.aliyuncs.com --instance myinstance --id STS.LTAI******************** --key 7NR2**************************************** --token STS.6MC2****************************************
If you have not activated Tablestore or created an instance, see Activate Tablestore and Create an instance. You can also activate the service and create an instance by using the CLI tool.
Basic operations
Verify the connection by running basic data operations.
Wide-column
Create a data table, write data, and read data to verify basic wide-column operations.
-
Create a data table.
create -t order --pk '[{"c":"id","t":"string"}]' -
Switch to the data table.
use --wc -t order -
Write a row of data.
put --pk '["id001"]' --attr '[{"c":"name","v":"test"},{"c":"age","v":20}]' -
Read the row.
get --pk '["id001"]'
For more wide-column operations, see Wide Column model.
Time-series
Create a time-series table for server monitoring and query the data to verify basic time-series operations.
The following steps record CPU metrics (measurement: cpu) for a host. The data source identifies the host, and tags record the region and operating system.
-
Create a time-series table.
create --ts -t mytable --ttl -1 -
Switch to the time-series table.
use --ts -t mytable -
Write time-series data.
putts --mn cpu --ds host=host001 --tags region=hangzhou,os=linux --fields cpu_usage=0.65,load=2.1 -
Query the time-series data.
getts --mn cpu --ds host=host001
For more time-series operations, see TimeSeries model.
View available commands
Run the help command to view all available commands. To view options for a specific command, run <command> help. For example, run alter help.