CreateInstance

更新时间:
复制 MD 格式

Create a Redis (open-source) instance with a classic or cloud-native architecture, or a Tair memory-optimized instance with a classic architecture. To create a Tair instance with a cloud-native architecture, use the CreateTairInstance API.

Operation description

Before you call this API, make sure you understand the billing methods and pricing of ApsaraDB for Tair.

This API is used to create a Redis Community Edition instance or a Tair Memory Type (Classic) instance. To create a Tair Cloud-native Edition instance, call the CreateTairInstance API.

Note

For instructions on how to perform this operation in the console and for guidance on instance selection, see Create a Redis instance.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

kvstore:CreateInstance

create

*DBInstance

acs:kvstore:{#regionId}:{#accountId}:instance/*

  • kvstore:InstanceClass
  • kvstore:Appendonly
  • kvstore:InstanceType
None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The ID of the region in which to create the instance. Call the DescribeRegions operation to get a list of region IDs.

cn-hangzhou

Token

string

No

A client-generated token to ensure the idempotence of the request. The token must be unique across requests, case-sensitive, and cannot exceed 64 ASCII characters.

ETnLKlblzczshOTUbOCz****

InstanceName

string

No

The name of the instance. The name must be 2 to 80 characters long, start with a letter (uppercase or lowercase) or a Chinese character, and not contain spaces or the characters @/:=”<>{[]}.

apitest

Password

string

No

The password for the instance. The password must be 8 to 32 characters long and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. The allowed special characters are !@#$%^&*()_+-=.

Pass!123456

Capacity

integer

No

The storage capacity of the instance, in MB.

Note

You must specify either the Capacity or the InstanceClass parameter.

16384

InstanceClass

string

No

The instance type. For example, redis.master.small.default specifies a 1 GB Community Edition (classic edition) instance with a standard, dual-replica architecture. For more information, see Instance specifications.

Note

You must specify either the Capacity or the InstanceClass parameter.

redis.master.small.default

ZoneId

string

No

The ID of the primary zone for the instance. You can call the DescribeZones operation to query available zones.

Note

You can also specify a secondary zone by using the SecondaryZoneId parameter. The primary and replica nodes are then deployed in the specified primary and secondary zones to create a dual-zone architecture for in-city disaster recovery. For example, you can set the ZoneId parameter to "cn-hangzhou-h" and the SecondaryZoneId parameter to "cn-hangzhou-g".

cn-hangzhou-h

SecondaryZoneId

string

No

The ID of the secondary zone. You can call the DescribeZones operation to query the latest list of zones.

Note

The value of this parameter cannot be the same as the value of the ZoneId parameter, and you cannot specify a multi-zone ID.

cn-hangzhou-g

ChargeType

string

No

The billing method. Valid values:

  • PrePaid: subscription.

  • PostPaid (default): pay-as-you-go.

PostPaid

NodeType

string

No

The node type. Valid values:

  • MASTER_SLAVE: high-availability (primary-replica)

  • STAND_ALONE: standalone (single-node)

  • double: primary-replica

  • single: standalone (single-node)

Note

Set this parameter to MASTER_SLAVE or STAND_ALONE for cloud native edition instances. Set this parameter to double or single for classic edition instances.

STAND_ALONE

NetworkType

string

No

The network type. Valid value:

  • VPC: Deploys the instance in a Virtual Private Cloud. This is the default value.

VPC

VpcId

string

No

The ID of the VPC.

vpc-bp1nme44gek34slfc****

VSwitchId

string

No

The ID of the vSwitch.

vsw-bp1e7clcw529l773d****

Period

string

No

The subscription duration, in months. Valid values: 1 to 9, 12, 24, 36, and 60.

Note

This parameter is available and required only when ChargeType is set to PrePaid.

12

BusinessInfo

string

No

The campaign ID or business information.

000000000

CouponNo

string

No

The coupon code. Default value: default.

youhuiquan_promotion_option_id_for_blank

SrcDBInstanceId

string

No

To create an instance from a backup, specify the ID of the source instance.

Note

This parameter must be used in conjunction with one of the following parameters: BackupId, ClusterBackupId (recommended for cloud native, cluster-architecture instances), or RestoreTime.

r-bp1zxszhcgatnx****

BackupId

string

No

The ID of the backup that you want to use to create the new instance. You can obtain backup IDs by calling the DescribeBackups operation. If the source instance has a cluster architecture, you must specify the backup IDs of all its shards, separated by commas (for example, "10**,11**,15**").

Note

If your source instance is a cloud native cluster instance, it is recommended to call DescribeClusterBackupList to get a cluster backup ID (for example, "cb-xx") and use the ClusterBackupId parameter instead. This avoids the need to specify the backup ID for each shard.

111111111

InstanceType

string

No

The instance type. Valid values:

  • Redis (default)

  • Memcache

Redis

EngineVersion

string

No

The Redis engine version. Valid values for classic edition instances:

Valid values for cloud native edition instances:

  • 5.0

  • 6.0 (Recommended)

  • 7.0

Note

The default value is 5.0.

Valid values:

  • 4.0 :

    4.0

  • 5.0 :

    5.0

  • 6.0 :

    6.0

  • 7.0 :

    7.0

  • 2.8 :

    2.8

5.0

PrivateIpAddress

string

No

The private IP address of the new instance.

Note

The IP address must be within the CIDR block of the specified vSwitch.

172.16.0.***

AutoUseCoupon

string

No

Specifies whether to use a coupon. Valid values:

  • true: Uses a coupon.

  • false (default): Does not use a coupon.

false

AutoRenew

string

No

Specifies whether to enable auto-renewal for the instance. Valid values:

  • true: Enables auto-renewal.

  • false (default): Disables auto-renewal.

true

AutoRenewPeriod

string

No

The auto-renewal duration, in months. Valid values: 1, 2, 3, 6, and 12.

Note

This parameter is required when AutoRenew is set to true.

3

ResourceGroupId

string

No

The ID of the resource group.

rg-resourcegroupid1

RestoreTime

string

No

The point in time to which you want to restore data, specified in the yyyy-MM-ddTHH:mm:ssZ (UTC) format.

2019-06-19T16:00:00Z

DedicatedHostGroupId

string

No

The ID of the dedicated host group. This parameter is required when you create a Redis instance in a dedicated host group.

dhg-uv4fnk6r7zff****

ShardCount

integer

No

The number of shards. This parameter is available only for cloud native edition instances.

  • A value of 1 creates an instance with a standard architecture.

  • A value greater than 1 creates an instance with a cluster architecture.

4

ReplicaCount

integer

No

The number of replicas in the primary zone. This parameter is available only for multi-replica cluster instances of the cloud native edition. You can specify a value from 1 to 4.

Note

When creating a multi-zone instance, you can use this parameter and SlaveReplicaCount to customize the number of replicas in the primary and secondary zones. The sum of ReplicaCount and SlaveReplicaCount cannot exceed 4.

2

SlaveReplicaCount

integer

No

The number of replicas in the secondary zone.

2

ReadOnlyCount

integer

No

The number of read-only replicas in the primary zone. This parameter is available only when creating a read/write splitting instance of the cloud native edition.

  • For a standard-architecture instance, the value must be an integer from 1 to 9.

  • For a cluster-architecture instance, the value must be an integer from 1 to 4. This specifies the number of read-only replicas for each data shard.

Note

If you create a multi-zone instance, you can use this parameter and SlaveReadOnlyCount to customize the number of read-only replicas in the primary and secondary zones.

  • The sum of this parameter and SlaveReadOnlyCount cannot exceed 9 for a standard-architecture instance.

  • The sum of this parameter and SlaveReadOnlyCount cannot exceed 4 for a cluster-architecture instance.

2

SlaveReadOnlyCount

integer

No

The number of read-only replicas in the secondary zone.

2

GlobalInstanceId

string

No

The ID of the distributed instance. This parameter is available only in Chinese mainland.

This parameter is required to add the new instance as a child of a distributed instance. For more information and the console procedure, see Add a child instance to a distributed instance.

gr-bp14rkqrhac****

GlobalInstance

boolean

No

Specifies whether to create the new instance as the first child instance of a distributed instance. Valid values:

  • true: Creates the instance as the first child instance.

  • false (default): Does not create the instance as the first child instance.

Note
  • If you set this parameter to true, the new instance must be a Tair memory-enhanced instance that runs Redis 5.0.

  • This parameter is available only in Chinese mainland.

false

Port

string

No

The service port of the instance. The port number must be between 1 and 65535. The default value is 6379.

6379

DryRun

boolean

No

Specifies whether to perform a dry run. Valid values:

  • true: Checks the request for validity without creating the instance. The system verifies required parameters, request format, and service limits. If the request is valid, the DryRunOperation error code is returned. If the request is invalid, an error message is returned.

  • false (default): Sends the request. If the request is valid, the instance is created.

false

GlobalSecurityGroupIds

string

No

The IDs of the security groups to associate with the instance. You can specify multiple security group IDs, separated by commas (,). IDs cannot be repeated.

Important This parameter is available only for cloud native edition instances. Security groups are not supported for classic edition instances.

g-zsldxfiwjmti0kcm****

Appendonly

string

No

Specifies whether to enable AOF persistence for the new instance. Valid values:

  • yes (default): Enables AOF persistence.

  • no: Disables AOF persistence.

Note

This parameter is available only for classic edition instances. AOF persistence cannot be configured for cloud native edition instances at creation.

Valid values:

  • no :

    Disable AOF

  • yes :

    Enable AOF

yes

ConnectionStringPrefix

string

No

The prefix of the connection string. The prefix must be 8 to 40 characters long, start with a lowercase letter, and contain only lowercase letters and digits.

Note

The full connection string is in the format: <prefix>.redis.rds.aliyuncs.com.

r-bp1zxszhcgatnx****

ParamGroupId

string

No

The ID of the parameter group. This ID must be globally unique.

Important This parameter is available only for cloud native edition instances.

rpg-test**

Tag

array<object>

No

The tags of the instance.

object

No

Object.

Key

string

No

The key of the tag.

Note
  • N represents the sequence number of the tag, from 1 to 20. You can add a maximum of 20 tags to an instance.

  • If the tag key does not exist, it is automatically created.

testkey

Value

string

No

The value for tag N.

Note

The N in Tag.N.Value specifies the sequence number of the tag. For example, Tag.1.Value specifies the value of the first tag, and Tag.2.Value specifies the value of the second tag.

testvalue

ClusterBackupId

string

No

The ID of the cluster backup. You can get this ID by calling the DescribeClusterBackupList operation. This parameter is available for some cloud native cluster instances.

  • This parameter is mutually exclusive with BackupId.

  • If this parameter is not available for your instance, you must specify the backup ID of each shard in the BackupId parameter (for example, "2158****20,2158****22").

cb-hyxdof5x9kqb****

RecoverConfigMode

string

No

Specifies which configurations to restore from the backup when creating an instance. Valid values include account, config, and whitelist. For example, to restore account settings, specify account. To restore multiple configurations, separate them with commas.

By default, this parameter is empty, which means no configurations are restored.

Note

This parameter is applicable only to cloud native edition instances. The source backup must contain the specified configurations. You can call the DescribeBackups operation and check the RecoverConfigMode field in the response to determine which configurations a backup contains.

whitelist,config,account

InstanceEndpointType

string

No

The connection endpoint type. This parameter is applicable only when you create a dual-zone, read/write splitting instance of the cloud native edition. If this parameter is not specified, AzIndependentEndpoint is used. Valid values:

  • AzIndependentEndpoint: (Default) Zone-Independent Endpoint. The primary and secondary zones each provide an independent connection string for zone-local access.

  • UnifiedEndpoint: Unified Endpoint. Provides a single connection string to access nodes in both zones, which may result in cross-zone access.

Important This parameter is applicable only to dual-zone, read/write splitting instances of the cloud native edition. For other instance types, only zone-independent endpoints are supported, and specifying UnifiedEndpoint has no effect.
Important The UnifiedEndpoint parameter is currently available only to allowlisted users. API calls will fail if you are not on the allowlist. To be added to the allowlist, submit a ticket.

AzIndependentEndpoint

MaintainStartTime

string

No

The start of the maintenance window. Specify the time in the HH:mmZ format (UTC). For example, to set the start time to 01:00 (UTC+8), specify 17:00Z.

Note

If this parameter is not specified, the maintenance window starts at 02:00 (UTC+8), which is 18:00 (UTC).

03:00Z

MaintainEndTime

string

No

The end time of the maintenance window. Specify the time in the HH:mmZ format (UTC). For example, to set the end time to 02:00 (UTC+8), specify 18:00Z.

Note

The duration of the maintenance window must be at least one hour.

Note

If this parameter is not specified, the maintenance window ends at 06:00 (UTC+8), which is 22:00 (UTC).

07:00Z

The following example shows a request that creates a Redis 7.0 instance with a cluster architecture.

{
  "RegionId": "cn-shenzhen",
  "InstanceName": "apitest",
  "Password": "D****23",
  "ZoneId": "cn-shenzhen-f",
  "ChargeType": "PrePaid",
  "InstanceClass": "redis.shard.with.proxy.small.ce",
  "NetworkType": "VPC",
  "Period": "1",
  "InstanceType": "Redis",
  "EngineVersion": "7.0",
  "ShardCount": 4,
  "SourceIp": "10.10.10.10"
}

Response elements

Element

Type

Description

Example

object

The response object.

VpcId

string

The ID of the VPC.

vpc-bp1nme44gek34slfc****

QPS

integer

The theoretical queries per second (QPS) of the instance.

100000

Capacity

integer

The storage capacity of the instance, in MB.

16384

ConnectionDomain

string

The private connection endpoint of the instance.

r-bp1zxszhcgatnx****.redis.rds.aliyuncs.com

ChargeType

string

The billing method. Valid values:

  • PrePaid: subscription

  • PostPaid: pay-as-you-go

PostPaid

NetworkType

string

The network type. Valid values:

  • CLASSIC: classic network

  • VPC: VPC

VPC

InstanceId

string

The ID of the instance.

r-bp1zxszhcgatnx****

Port

integer

The connection port of the instance.

6379

Config

string

The configurations of the instance.

{\"EvictionPolicy\":\"volatile-lru\",\"hash-max-ziplist-entries\":512,\"zset-max-ziplist-entries\":128,\"zset-max-ziplist-value\":64,\"set-max-intset-entries\":512,\"hash-max-ziplist-value\":64}

RegionId

string

The ID of the region.

cn-hongkong

EndTime

string

The expiration time of the subscription instance. The time is displayed in UTC. Format: yyyy-MM-ddTHH:mm:ssZ.

2019-01-18T16:00:00Z

VSwitchId

string

The ID of the vSwitch.

vsw-bp1e7clcw529l773d****

RequestId

string

The ID of the request.

5DEA3CC9-F81D-4387-8E97-CEA40F09****

NodeType

string

The node type. Valid values:

  • STAND_ALONE: standalone

  • MASTER_SLAVE: primary-replica

MASTER_SLAVE

Connections

integer

The maximum number of connections.

10000

Bandwidth

integer

The bandwidth of the instance. Unit: MB/s.

32

InstanceName

string

The name of the instance.

apitest

ZoneId

string

The ID of the zone.

cn-hangzhou-b

InstanceStatus

string

The state of the instance. For this operation, the returned value is always Creating.

Creating

PrivateIpAddr

string

The private IP address of the instance.

172.16.0.10

UserName

string

The username of the account. By default, the username is the same as the instance ID.

r-bp1zxszhcgatnx****

OrderId

integer

The ID of the order.

2084452111111

Examples

Success response

JSON format

{
  "VpcId": "vpc-bp1nme44gek34slfc****",
  "QPS": 100000,
  "Capacity": 16384,
  "ConnectionDomain": "r-bp1zxszhcgatnx****.redis.rds.aliyuncs.com",
  "ChargeType": "PostPaid",
  "NetworkType": "VPC",
  "InstanceId": "r-bp1zxszhcgatnx****",
  "Port": 6379,
  "Config": "{\\\"EvictionPolicy\\\":\\\"volatile-lru\\\",\\\"hash-max-ziplist-entries\\\":512,\\\"zset-max-ziplist-entries\\\":128,\\\"zset-max-ziplist-value\\\":64,\\\"set-max-intset-entries\\\":512,\\\"hash-max-ziplist-value\\\":64}",
  "RegionId": "cn-hongkong",
  "EndTime": "2019-01-18T16:00:00Z",
  "VSwitchId": "vsw-bp1e7clcw529l773d****",
  "RequestId": "5DEA3CC9-F81D-4387-8E97-CEA40F09****",
  "NodeType": "MASTER_SLAVE",
  "Connections": 10000,
  "Bandwidth": 32,
  "InstanceName": "apitest",
  "ZoneId": "cn-hangzhou-b",
  "InstanceStatus": "Creating",
  "PrivateIpAddr": "172.16.0.10",
  "UserName": "r-bp1zxszhcgatnx****",
  "OrderId": 2084452111111
}

Error codes

HTTP status code

Error code

Error message

Description

400 ZoneIdNotFound Specify iz not support switch network. Unable to find Availability Zone
400 InvalidShardInfo.Format Shard total number is out of range.
400 InvalidInstancelevel Specified Instance level dose not match gdc other member instance level.
400 InvalidBackupLogStatus Backup logs are not enabled for the specified source instance.
400 InvalidStatus Specified instance status is Modifying. Specified instance status is Modifying.
400 SecurityRisk.AuthVerification we have detected a risk with your default payment method. An email and notification has been sent to you. Please re-submit your order before after verificaiton.
400 MissingParameter Period is mandatory for this action.
400 InvalidToken.Malformed The Specified parameter Token is not valid.
400 InvalidInstanceName.Malformed The Specified parameter InstanceName is not valid.
400 InvalidPassword.Malformed The Specified parameter Password is not valid.
400 InsufficientBalance Your account does not have enough balance.
400 QuotaExceed.AfterpayInstance Living afterpay instances quota exceeded.
400 InvalidCapacity.NotFound The Capacity provided does not exist in our records.
400 ResourceNotAvailable Resource you requested is not available for finance user.
400 PaymentMethodNotFound No payment method has been registered on the account.
400 IdempotentParameterMismatch Request uses a client token in a previous request but is not identical to that request. Idempotent check.
400 QuotaNotEnough Quota not enough in this zone.
400 QuotaExceed Living afterpay instances quota exceed.
400 VpcServiceError Invoke vpc service failed.
400 IzNotSupportVpcError Specify iz not support vpc.
400 InvalidvSwitchId The vpc does not cover the vswitch.
400 InvalidIzNo.NotSupported The Specified vpc zone not supported.
400 InvalidAccountPassword.Format Specified account password is not valid.
400 InstanceClass.NotMatch Current instance class and instance type is not match.
400 InvalidVPCId.NotFound Specified virtual vpc is not found. The specified VPC is not found. Check whether the VPC ID is correct.
400 AccountMoneyValidateError Account money validate error.
400 RequestTokenConflict Specified request token conflict.
400 InvalidIPNotInSubnet Error ip not in subnet.
400 InvalidEngineVersion.Malformed Specified engine version is not valid. The error message returned because the instance engine version is invalid.
400 Zone.Closed The specified zone is closed.
400 VSwithNotBelongToNotVpcFault The vSwitch does not belong to current vpc.
400 PayIllegalAgreement Pay mayi with holding agreement illegal.
400 IllegalParamError validateSaleConditionWithSubArticle failed.
400 CASH_BOOK_INSUFFICIENT No payment method is specified for your account. We recommend that you add a payment method or maitain a minimum prepayment balance of INR 1000.
400 InvalidRegion.Format Specified Region is not valid. The specified region is invalid.
400 DryRunOperation Request validation has been passed with DryRun flag set. The request performs the pre-check operation and has passed the pre-check, and does not create an instance.
400 ResourceGroupNotExist The Specified ResourceGroupId does not exist.
403 RealNameAuthenticationError Your account has not passed the real-name authentication yet.
403 AuthorizationFailure The request processing has failed due to authorization failure.
403 TokenServiceError The specified token is duplicated, please change it.
404 InvalidCapacity.NotFound The Capacity provided does not exist in our records. The specified storage specification does not exist.
404 InvalidvSwitchId The Specified vSwitchId zone not supported.
404 InvalidVpcIdOrVswitchId.NotSupported The Specified vpcId or vSwitchId not supported.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.