更新时间:2023-12-12 GMT+08:00

创建DCS高频场景示例

本节介绍了使用API购买DCS实例过程中的一些常见问题及处理方法。

表1 购买DCS实例常见问题及处理方法

常见问题

处理方法

使用API购买实例时设置副本数

使用API购买的实例,副本数的值取决于在购买时输入的spec_code参数,为调用查询产品规格响应示例中replica_count的值。

获取子网ID

通过查询子网ID接口,获取正确的ID供购买实例时配置。

购买实例时可用区资源不足

可用区资源不足会导致创建实例失败,可通过调用查询产品规格响应示例中flavors_available_zones.az_codes的值来确保在购买实例时选择充足资源的可用区。

查看资源的可用配额

通过调用查询租户配额接口,通过quota值可确定可以创建的实例最大数和总内存的配额限制。

使用API购买实例时设置副本数

使用API购买实例后,副本数的值取决于在购买时输入的spec_code参数。副本数即为查询产品规格接口响应示例的replica_count值。

请求示例:

GET https://{dcs_endpoint}/v2/flavors?cache_mode={cache_mode}&engine={engine}&engine_version={engine_version}&cpu_type={cpu_type}&capacity={capacity}

响应示例:

{
 "flavors": [
  {
   "dec": false,
   "spec_code": "redis.ha.xu1.large.r4.2",
   "cloud_service_type_code": "hws.service.type.dcs",
   "cloud_resource_type_code": "hws.resource.type.dcs3",
   "cache_mode": "ha",
   "engine": "redis",
   "engine_version": "4.0;5.0",
   "product_type": "generic",
   "cpu_type": "x86_64",
   "storage_type": "DRAM",
   "capacity": [
    "2"
   ],
   "billing_mode": [
    "Hourly",
    "Monthly",
    "Yearly"
   ],
   "tenant_ip_count": 4,
   "pricing_type": "normal",
   "is_dec": false,
   "attrs": [
    {
     "capacity": "2",
     "name": "max_memory",
     "value": "2"
    },
    {
     "capacity": "2",
     "name": "max_connections",
     "value": "50000"
    },
    {
     "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",
      "15dcd3f789cb4fc088dbdece9c5eb547",
      "2dcb154ac2724a6d92e9bcc859657c1e",
      "effdcbc7d4d64a02aa1fa26b42f56533"
     ],
     "az_codes": [
      "xx-xx-xx1",
      "xx-xx-xx2",
      "xx-xx-xx3",
      "xx-xx-xx4"
     ]
    }
   ],
   "replica_count": 4,
   "inquery_spec_code": null
  }
 ]
}

在购买实例时,输入的spec_code参数须与capacity参数一一对应。

获取子网ID

在购买实例时配置正确的子网ID,才能够成功连接实例。可通过GET /v1/{project_id}/subnets?{vpc_id}获取准确子网ID,其中vpc_id可通过GET /v1/{project_id}/vpcs接口获取。

获取vpc_id的请求示例:

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

{vpc_endpoint}信息,请从地区和终端节点获取。

获取vpc_id的响应示例:

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

获取子网ID的请求示例:

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

获取子网ID的响应示例:

{
	"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": "xxxxxx",
		"neutron_network_id": "b0d6e0ac-fcce-4e11-a4a6-707e851ae1c3",
		"neutron_subnet_id": "3d4ccce0-cadc-4af4-8c21-14d2857ffe5e",
		"extra_dhcp_opts": []
	}]
}

购买实例时可用区资源不足

在购买实例时,如需要查询某一规格在某可用区是否资源充足,可通过调用查询产品规格查看规格所在可用区的详细信息,通过flavors_available_zones的值判断该规格可选的可用区。

如在某region、规格为redis.ha.xu1.large.r2.2的资源充足可用区的信息,请求示例:

https://{dcs_endpoint}/v2/05041fffa40025702f6dc009cc6f8f33/flavors?spec_code=redis.ha.xu1.large.r2.2

响应示例:

{
 "flavors": [
  {
   "dec": false,
   "spec_code": "redis.ha.xu1.large.r2.2",
   "cloud_service_type_code": "hws.service.type.dcs",
   "cloud_resource_type_code": "hws.resource.type.dcs3",
   "cache_mode": "ha",
   "engine": "redis",
   "engine_version": "4.0;5.0",
   "product_type": "generic",
   "cpu_type": "x86_64",
   "storage_type": "DRAM",
   "capacity": [
    "2"
   ],
   "billing_mode": [
    "Hourly",
    "Monthly",
    "Yearly"
   ],
   "tenant_ip_count": 2,
   "pricing_type": "normal",
   "is_dec": false,
   "attrs": [
    {
     "capacity": "2",
     "name": "max_memory",
     "value": "2"
    },
    {
     "capacity": "2",
     "name": "max_connections",
     "value": "50000"
    },
    {
     "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",
      "15dcd3f789cb4fc088dbdece9c5eb547",
      "2dcb154ac2724a6d92e9bcc859657c1e",
      "effdcbc7d4d64a02aa1fa26b42f56533"
     ],
     "az_codes": [
      "xx-xx-xx1",
      "xx-xx-xx2",
      "xx-xx-xx3",
      "xx-xx-xx4"
     ]
    }
   ],
   "replica_count": 2,
   "inquery_spec_code": null
  }
 ]
}

其中flavors_available_zones罗列出了该规格资源充足的可用区。

查看资源的可用配额

如需查询当前账号的资源配额信息,包括已使用的配额,可以通过调用查询租户配额接口。

请求示例:

GET https://{dcs_endpoint}/v2/05041fffa40025702f6dc009cc6f8f33/quota

响应示例:

{
 "quotas": {
  "resources": [
   {
    "quota": 160,
    "used": 1,
    "type": "instance",
    "min": 0,
    "max": 2147483647,
    "unit": null
   },
   {
    "quota": 64000,
    "used": 0,
    "type": "ram",
    "min": 0,
    "max": 1048576,
    "unit": "GB"
   }
  ]
 }
}
  • 当type为instance时,max表示可申请实例配额的最大值,min表示可申请实例配额的最小值。
  • 当type为ram时,max表示可申请内存配额的最大值,min表示可申请内存配额的最小值。
  • quota为可以创建的实例最大数和总内存的配额限制。
  • used为已创建的实例个数和已使用的内存配额。