Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Distributed Cache Service/ API Reference/ Examples/ Example 1: Creating a DCS Redis Instance

Example 1: Creating a DCS Redis Instance

Updated on 2024-03-05 GMT+08:00

Scenario

This section describes how to create a DCS Redis instance by calling APIs. For details about how to call APIs, see Calling APIs.

A 2 GB single-node DCS Redis 5.0 instance is used as an example. The instance uses the Arm CPU architecture and can be accessed without a password.

Involved APIs

When creating a DCS Redis instance, you need to query the product specifications, VPC, and subnet. Call APIs to perform the following steps:

Step 1: Determine the VPC

  1. Query VPCs.

    • URI

      URI format: GET /v1/{project_id}/vpcs

    • Example request

      GET https://{vpc_endpoint}/v1/7d80ae32f57b499eb8781f9a9f57c538/vpcs

      To obtain the value of {vpc_endpoint}, see Regions and Endpoints.

    • Example response
      {
      	"vpcs": [{
      		"id": "743bf021-2c2d-4511-aeac-85bd48c06af7",
      		"name": "vpc-d2d4",
      		"description": "",
      		"cidr": "192.168.0.0/16",
      		"status": "OK",
      		"routes": [],
      		"enterprise_project_id": "0"
      	}]
      }

  2. Record the required VPC ID.

Step 2: Determine the Subnet

  1. Query subnets.

    • URI

      URI format: GET /v1/{project_id}/subnets?{vpc_id}

    • Example request

      GET https://{vpc_endpoint}/v1/7d80ae32f57b499eb8781f9a9f57c538/subnets?vpc_id=743bf021-2c2d-4511-aeac-85bd48c06af7

      To obtain the value of {vpc_endpoint}, see Regions and Endpoints.

    • Example response
      {
      	"subnets": [{
      		"id": "b0d6e0ac-fcce-4e11-a4a6-707e851ae1c3",
      		"name": "subnet-d2e4",
      		"description": "",
      		"cidr": "192.168.0.0/24",
      		"dnsList": ["100.125.1.250",
      		"100.125.129.250"],
      		"status": "ACTIVE",
      		"vpc_id": "743bf021-2c2d-4511-aeac-85bd48c06af7",
      		"ipv6_enable": false,
      		"gateway_ip": "192.168.0.1",
      		"dhcp_enable": true,
      		"primary_dns": "100.125.1.250",
      		"secondary_dns": "100.125.129.250",
      		"availability_zone": "cn-southwest-2a",
      		"neutron_network_id": "b0d6e0ac-fcce-4e11-a4a6-707e851ae1c3",
      		"neutron_subnet_id": "3d4ccce0-cadc-4af4-8c21-14d2857ffe5e",
      		"extra_dhcp_opts": []
      	}]
      }

  2. Record the required subnet ID.

Step 3: Determine the Product Specifications

  1. Query product specifications.

    • URI

      URI format: GET /v2/{project_id}/flavors?spec_code={spec_code}&cache_mode={cache_mode}&engine={engine}&engine_version={engine_version}&cpu_type={cpu_type}&capacity={capacity}

    • Example request

      GET https://{dcs_endpoint}/v2/666486c2d9b948c1bbea57e714d744fa/flavors?cache_mode=single&engine=Redis&engine_version=5.0&cpu_type=aarch64&capacity=2

      To obtain the value of {dcs_endpoint}, see Regions and Endpoints.

    • Example response
      [{
      	"dec": false,
      	"spec_code": "redis.single.au1.large.2",
      	"cloud_service_type_code": "hws.service.type.dcs",
      	"cloud_resource_type_code": "hws.resource.type.dcs3",
      	"cache_mode": "single",
      	"engine": "redis",
      	"engine_version": "4.0;5.0",
      	"product_type": "generic",
      	"cpu_type": "aarch64",
      	"storage_type": "DRAM",
      	"capacity": ["2"],
      	"billing_mode": ["Hourly",
      	"RI",
      	"Monthly",
      	"Yearly"],
      	"tenant_ip_count": 1,
      	"pricing_type": "normal",
      	"is_dec": false,
      	"attrs": [{
      		"capacity": "2",
      		"name": "max_memory",
      		"value": "2"
      	},
      	{
      		"capacity": "2",
      		"name": "max_connections",
      		"value": "10000"
      	},
      	{
      		"capacity": "2",
      		"name": "sharding_num",
      		"value": "1"
      	},
      	{
      		"capacity": "2",
      		"name": "proxy_num",
      		"value": "0"
      	},
      	{
      		"capacity": "2",
      		"name": "db_number",
      		"value": "256"
      	},
      	{
      		"capacity": "2",
      		"name": "max_clients",
      		"value": "10000"
      	},
      	{
      		"capacity": "2",
      		"name": "max_bandwidth",
      		"value": "128"
      	}],
      	"flavors_available_zones": [{
      		"capacity": "2",
      		"unit": "GB",
      		"available_zones": ["a0865121f83b41cbafce65930a22a6e8",
      		"effdcbc7d4d64a02aa1fa26b42f56533"],
      		"az_codes": ["cn-north-4b",
      		"cn-north-4a"]
      	}]
      }]

  2. Select a product as required and record the product specification code and the code of the AZ where resources are available.

Step 4: Create an Instance

  • URI

    URI format: POST /v2/{project_id}/instances

  • Example request

    POST https://{dcs_endpoint}/v2/666486c2d9b948c1bbea57e714d744fa/instances

    To obtain the value of {dcs_endpoint}, see Regions and Endpoints.

    Body:

    {
    	"az_codes": ["cn-north-4a"],
    	"capacity": 2,
    	"engine": "Redis",
    	"engine_version": "5.0",
    	"name": "dcs-api-test",
    	"no_password_access": true,
    	"security_group_id": "1982d3a8-67a0-4fc9-a850-bc42a26ba2c0",
    	"spec_code": "redis.single.xu1.large.2",
    	"subnet_id": "b0d6e0ac-fcce-4e11-a4a6-707e851ae1c3",
    	"vpc_id": "743bf021-2c2d-4511-aeac-85bd48c06af7"
    }
  • Example response
    {
    	"instances": [{
    		"instance_id": "21bc7b53-2494-4f10-bb0b-c0b913d9e329",
    		"instance_name": "dcs-api-test"
    	}]
    }

    For details about the parameters for creating a DCS Redis instance, see Creating a DCS Instance.

Step 5: Query the Creation Result

  • URI

    URI format: GET /v2/{project_id}/instances/{instance_id}

  • Example request

    GET https://{dcs_endpoint}/v2/666486c2d9b948c1bbea57e714d744fa/instances/21bc7b53-2494-4f10-bb0b-c0b913d9e329

    To obtain the value of {dcs_endpoint}, see Regions and Endpoints.

  • Example response
    {
    	"free": null,
    	"max_memory": 2048,
    	"used_memory": 1,
    	"instance_id": "21bc7b53-2494-4f10-bb0b-c0b913d9e329",
    	"name": "dcs-api-test",
    	"resource_spec_code": "redis.single.au1.large.2",
    	"engine": "Redis",
    	"engine_version": "5.0",
    	"internal_version": null,
    	"charging_mode": 0,
    	"capacity": 2,
    	"capacity_minor": null,
    	"vpc_id": "743bf021-2c2d-4511-aeac-85bd48c06af7",
    	"vpc_name": "vpc-d2d4",
    	"ip": "192.168.0.100",
    	"domain_name": "redis-88a7bbb-dcs-api-test.dcs.huaweicloud.com",
    	"readonly_domain_name": null,
    	"port": 6379,
    	"status": "RUNNING",
    	"freeze_scene": null,
    	"created_at": "2020-06-05T03:30:36.273Z",
    	"update_at": "2020-06-05T03:30:47.231Z",
    	"error_code": null,
    	"user_id": "d53977d1adfb49c5b025ba7d33a13fd7",
    	"user_name": "paas_dcs_a00421997_02",
    	"maintain_begin": "02:00:00",
    	"maintain_end": "06:00:00",
    	"no_password_access": "true",
    	"access_user": null,
    	"enable_publicip": false,
    	"publicip_id": null,
    	"publicip_address": null,
    	"enable_ssl": false,
    	"service_upgrade": false,
    	"service_task_id": "",
    	"enterprise_project_id": "0",
    	"security_group_id": null,
    	"tags": [],
    	"product_type": "generic",
    	"cpu_type": "aarch64",
    	"storage_type": "DRAM",
    	"launched_at": "2020-06-05T03:30:47.238Z",
    	"is_free": null,
    	"libos": false,
    	"cache_mode": "single",
    	"available_zones": ["d539378ec1314c85b76fefa3f7071458"],
    	"subnet_id": "a4112635-3ec0-471c-95c3-5cf49b9533af",
    	"backend_addrs": null,
    	"crr_role": null,
    	"cloud_service_type_code": "hws.service.type.dcs",
    	"cloud_resource_type_code": "hws.resource.type.dcs3",
    	"support_slow_log_flag": null,
    	"ipv6": null,
    	"enable_ipv6": false,
    	"description": "",
    	"product_id": "redis.single.au1.large.2-h",
    	"security_group_name": null,
    	"subnet_name": "dcs-beta",
    	"order_id": null,
    	"subnet_cidr": "192.168.0.0/24",
    	"task": null,
    	"instance_backup_policy": null,
    	"enterprise_project_name": null
    }

    If the instance status is RUNNING, the instance has been created successfully.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback