Examples
Scenarios
Call an API to create a DCS Redis instance that meets the computing and storage requirements of services.
The following presents how to call the API described in Creating a DCS Instance to create a DCS instance. For more information on how to call APIs, see Calling APIs.
Prerequisites
- IAM endpoint obtained from Regions and Endpoints.
- DCS endpoint obtained from Regions and Endpoints.
- Project ID. For details, see Obtaining a Project ID.
Creating a DCS Redis Instance
The following example shows how to create a DCS instance with the simplest configurations:
{
"name": "dcs-demo",
"engine": "Redis",
"engine_version": "3.0",
"capacity": 2,
"no_password_access": true,
"vpc_id": "c71d9731-9b0c-43e9-ab2a-716af9d9fd55",
"subnet_id": "1aa8068b-6846-4dae-bc27-bb923ab9b39c",
"product_id": "00301-31101-0--0",
"available_zones":["d573142f24894ef3bd3664de068b44b0"],
"security_group_id": "0cc8fdb7-872a-49da-a062-88ccc39463b5"
} The parameters in this example indicate a 2 GB DCS Redis 3.0 instance with password-free access.
- name: a customized DCS instance name.
- engine: cache engine, which is either Redis or Memcached.
- engine_version: cache engine version. When the cache engine is Redis, the version can be 3.0, 4.0, or 5.0.
- capacity: cache capacity in GB, which can be queried by calling the API described in Querying Service Specifications.
- no_password_access: whether the instance can be accessed without a password. false: the instance must be accessed with a password. true: the instance is accessed without a password.
- vpc_id: ID of the VPC where the instance resides. You can query the VPC ID by logging in to the VPC console or by calling the API described in Querying VPCs.
- subnet_id: ID of the VPC subnet. You can query the subnet ID by logging in to the VPC console or by calling the API described in Querying Subnets.
- product_id: specification ID of the DCS service that is being purchased, which can be queried by calling the API described in Querying Service Specifications.
- available_zones: ID of the AZ where the cache node resides and which has available resources, which can be queried by calling the API described in Querying AZ Information (Unavailable Soon).
- security_group_id: ID of the security group. You can query the security group ID by logging in to the VPC console or by calling the API described in Querying Security Groups Details.
Creating a DCS Redis 3.0 Instance with Public Access
To create a DCS instance with public access, add the enable_publicip field in the request and bound an elastic IP address (EIP) to the instance.
To enable public access, you must disable password-free access and configure a password for the instance.
Currently, public access is supported only by DCS Redis 3.0 instances.
The following is an example:
{
"name": "dcs-demo001",
"engine": "Redis",
"engine_version": "3.0",
"capacity": 2,
"vpc_id": "c71d9731-9b0c-43e9-ab2a-716af9d9fd55",
"subnet_id": "1aa8068b-6846-4dae-bc27-bb923ab9b39c",
"product_id": "00301-31101-0--0",
"available_zones":["d573142f24894ef3bd3664de068b44b0"],
"security_group_id": "0cc8fdb7-872a-49da-a062-88ccc39463b5",
"no_password_access": false,
"password": "********",
"enable_publicip": true,
"publicip_id": "238e9b49-f714-4933-ad48-6c4f5a75c64c"
} Parameter description:
- no_password_access: whether the instance can be accessed without a password. false: the instance must be accessed with a password. true: the instance is accessed without a password.
- password: password for accessing the instance. For details about password complexity requirements, see DCS Password Complexity Requirements.
- enable_publicip: whether to enable public access for the instance. false: do not enable public access. true: enable public access.
- publicip_id: ID of the EIP bound to the instance. You can query the EIP by logging in to the EIPs console or by calling the API described in Querying EIPs.
Creating a DCS Redis Instance with Backup Policies
To create a master/standby or cluster DCS instance with backup policies, add the instance_backup_policy field in the request, which specifies the backup policy and backup plan. The following is an example:
{
"name": "dcs-demo003",
"engine": "Redis",
"engine_version": "3.0",
"capacity": 2,
"no_password_access": true,
"vpc_id": "c71d9731-9b0c-43e9-ab2a-716af9d9fd55",
"subnet_id": "1aa8068b-6846-4dae-bc27-bb923ab9b39c",
"product_id": "00301-31101-0--0",
"available_zones": ["d573142f24894ef3bd3664de068b44b0"],
"security_group_id": "0cc8fdb7-872a-49da-a062-88ccc39463b5",
"instance_backup_policy": {
"save_days": 1,
"backup_type": "auto",
"periodical_backup_plan": {
"begin_at": "16:00-17:00",
"period_type": "weekly",
"backup_at": ["1",
"2",
"3",
"4",
"5",
"6",
"7"],
"timezone_offset": "+0800"
}
}
} - save_days: number of days that the backup data is retained.
- backup_type: backup mode. auto: scheduled backup. manual: manual backup.
- periodical_backup_plan: backup plan, which is detailed in Creating a DCS Instance.
Last Article: Response
Next Article: Lifecycle Management APIs
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.