This topic describes how to use the Tablestore CLI to manage Tablestore instances.

Activate Tablestore

If Tablestore is activated, skip this operation. You must activate Tablestore only once. You are not charged when you activate Tablestore.

Run the following command to activate Tablestore:
enable_service
The following result is returned:
Your service is enabled.

Create an instance

Create an instance in a specified region.

Notice The instance name must be globally unique within the region. If an error indicating that the instance name that you specify is the same as the name of an existing instance occurs, specify a new instance name.
  • Command syntax
    create_instance -d description -n instanceName -r regionId
    The following table describes the parameters that you can configure to create an instance in a specified region.
    Parameter Required Example Description
    -n Yes myinstance The name of the instance. For more information, see Instance.
    -r Yes cn-hangzhou The region ID of the instance. For more information, see Region.
    -d No "First instance created by CLI." The description of the instance.
  • Example

    The following sample code shows how to create an instance named myinstance in the China (Hangzhou) region:

    create_instance -d "First instance created by CLI." -n myinstance -r cn-hangzhou

Query information about an instance

Query information about an instance, such as the instance name, creation time, and the ID of the account to which the instance belongs.

  • Command syntax
    describe_instance -r regionId -n instanceName
  • Examples
    The following sample code shows how to query information about the instance named myinstance in the China (Hangzhou) region:
    describe_instance -r cn-hangzhou -n myinstance
    The following result is returned:
    {
        "Status": 1,
        "WriteCapacity": 5000,
        "ReadCapacity": 5000,
        "ClusterType": "SSD",
        "Timestamp": "",
        "UserId": "643941",
        "InstanceName": "myinstance",
        "CreateTime": "2021-10-31 14:19:43",
        "Network": "NORMAL",
        "Description": "First instance created by CLI.",
        "Quota": {
            "EntityQuota": 64
        },
        "TagInfos": {
            "TagInfo": []
        }
    }

Query instances

Query all instances in a specified region.

  • Command syntax
    list_instance -r regionId
  • Examples

    The following sample code shows how to query all instances in the China (Hangzhou) region:

    list_instance -r cn-hangzhou
    The following table describes the parameter that you can configure to query all instances in a specified region.
    Parameter Required Example Description
    -r Yes cn-hangzhou The ID of the region.
    The following result is returned:
    Note If no instance is created in the specified region, the returned result is empty.
    [
        "myinstance"
    ]

Configure an instance

Specify the endpoint of the instance based on the type of your network.

  • Command syntax
    config --endpoint endpoint --instance instanceName
    The following table describes the parameters that you can configure for an instance.
    Parameter Required Example Description
    --endpoint Yes http://myinstance.cn-hangzhou.ots.aliyuncs.com The endpoint of the instance, which supports two network types: Internet and virtual private cloud (VPC). Specify the endpoint of the instance based on your business requirements. The format of the endpoint must comply with the following rules:
    • Public: http(s)://<instance_name>.<region_id>.ots.aliyuncs.com
    • VPC: http(s)://<instance_name>.<region_id>.vpc.tablestore.aliyuncs.com
    --instance Yes myinstance The name of the instance.
  • Examples

    The following sample code shows how to configure the public endpoint for the instance named myinstance in the China (Hangzhou) region:

    config --endpoint http://myinstance.cn-hangzhou.ots.aliyuncs.com --instance myinstance
    The following result is returned:
    {
        "Endpoint": "http://myinstance.cn-hangzhou.ots.aliyuncs.com",
        "AccessKeyId": "NTSVLeBHzgX2iZfcaXXPJ****",
        "AccessKeySecret": "7NR2DiotscDbauohSq9kSHX8BDp99bjs7eNpCR7o****",
        "Instance": "myinstance"
    }
    The following table describes the response parameters.
    Parameter Required Example Description
    Endpoint No https://myinstance.cn-hangzhou.ots.aliyuncs.com The endpoint of the instance. For more information, see Endpoint.
    Instance No myinstance The name of the instance.
    AccessKeyId Yes NTSVLeBHzgX2iZfcaXXPJ**** The AccessKey ID and AccessKey secret of an Alibaba Cloud account or a RAM user.
    AccessKeySecret Yes 7NR2DiotscDbauohSq9kSHX8BDp99bjs7eNpCR7o****