
# 查询实例的组件列表 - QueryingtheComponentsofaDBInstance
#### 功能介绍
查询实例的所有组件信息。
- 调用接口前，您需要了解API [认证鉴权](https://support.huaweicloud.com/api-gaussdb/gaussdb_api_011.html)。
- 调用接口前，您需要提前获取到[地区和终端节点](https://developer.huaweicloud.com/endpoint)。
 
#### 调试
您可以在[API Explorer](https://apiexplorer.developer.huaweicloud.com/apiexplorer/doc?product=GaussDBforopenGauss&api=ListComponentInfos)中调试该接口。
#### URI
GET /v3/{project_id}/instances/{instance_id}/components
表1参数说明 
| 名称                   | 是否必选 | 参数类型    | 说明                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|:---|
| project_id           | 是    | String  | **参数解释：** 租户在某一Region下的项目ID。 获取方法请参见[获取项目ID](https://support.huaweicloud.com/api-gaussdb/gaussdb_api_196.html)。 **约束限制：** 不涉及。 **取值范围：** 只能由英文字母、数字组成，且长度为32个字符。 **默认取值**： 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| instance_id          | 是    | String  | **参数解释：** 实例ID，此参数是用户创建实例的唯一标识。请参考[查询数据库实例列表 - QueryingDBInstances](https://support.huaweicloud.com/api-gaussdb/gaussdb_api_328.html)接口获取实例ID。 **约束限制：** 不涉及。 **取值范围：** 只能由英文字母、数字组成，且长度为36个字符。 **默认取值** **：** 不涉及。 |
| limit                | 否    | Integer | **参数解释：** 查询记录数。例如该参数设定为10，则查询结果最多只显示10条记录。单位：条。 **约束限制：** 不涉及。 **取值范围：** 最小值为1，最大值为100。 **默认取值** **：** 100                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| offset               | 否    | Integer | **参数解释：** 索引位置，偏移量。从第一条数据偏移offset条数据后开始查询，例如：该参数指定为0，limit指定为10，则只展示第1-10条数据。 **约束限制：** 必须为数字，不能为负数。 **取值范围：** 最小值为0，最大值为100。 **默认取值** **：** 默认为0（偏移0条数据，表示从第一条数据开始查询）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| component_type       | 否    | String  | **参数解释：** 组件类型，过滤拿到需要的组件类型的组件信息。传参数会查询对应组件信息。 **约束限制：** 不涉及。 **取值范围：** - ALL：查询所有组件类型。  - CN：查询CN组件类型。  - DN：查询DN组件类型。  - CM：查询CMS组件类型。  - GTM：查询GTM组件类型。  - ETCD：查询ETCD组件类型。   **默认取值** **：** ALL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| availability_zone_id | 否    | String  | **参数解释：** 可用区编号，筛选符合条件的组件。 **约束限制：** 不涉及。 **取值范围：** 不涉及。 **默认取值** **：** 默认为ALL，查询实例所有可用区上的节点的组件信息。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | **参数解释：** 用户Token。 通过调用IAM服务[获取用户Token](https://support.huaweicloud.com/api-iam/iam_30_0001.html)接口获取。 请求响应成功后在响应消息头中包含的"X-Subject-Token"的值即为Token值。 **约束限制：** 不涉及。 **取值范围：** 不涉及。 **默认取值** **：** 不涉及。 |
| X-Language   | 否    | String | **参数解释：** 指定接口返回信息的语言类型。 **约束限制：** 不涉及。 **取值范围：** - **zh-cn**：中文  - **en-us**：英文   **默认取值** **：** **en-us**                     |
   
#### 响应参数
表3参数说明 
| 名称          | 参数类型             | 说明                                                                                                                                                                                                                        |
|:---|:---|:---|
| nodes       | Array of objects | **参数解释** **：** 组件详情。 详情请参见[表4]。 |
| total_count | Integer          | **参数解释** **：** 组件总数，单位：个。 **取值范围** **：** 不涉及。                               |
   
 表4nodes说明 
| 名称                   | 参数类型             | 说明                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|:---|:---|:---|
| id                   | String           | **参数解释** **：** 节点ID。 **取值范围** **：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| components           | Array of objects | 参数解释**：** 该实例节点下的组件信息列表，详情请参见[表5]。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| name                 | String           | **参数解释** **：** 节点名称。 **取值范围** **：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| availability_zone_id | String           | **参数解释** **：** 节点所在可用区编码。 **取值范围** **：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| description          | String           | **参数解释** **：** 可用区描述信息。 **取值范围** **：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| status               | String           | **参数解释** **：** 节点状态。 **取值范围** **：** - normal：节点正常。  - abnormal：节点异常。  - creating：节点正在创建。  - createfail：节点创建失败。   |
   
 表5components说明 
| 名称             | 参数类型   | 说明                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
|:---|:---|:---|
| id             | String | **参数解释** **：** 组件ID。 **取值范围** **：** - GTM：Global Transaction Manager，全局事务管理器。用于管理事务状态的部件。  - CMS：Cluster Management Server，集群管理组件。是用于管理集群状态的部件。  - DN：Data Node，和CN对应的概念。负责实际执行表数据的存储、查询操作。  - CN：Coordinator Node，负责数据库系统元数据存储、查询任务的分解和部分执行，以及将DN中查询结果汇聚在一起。  - ETCD：The unix "/etc" folder and distributed systems，分布式键值存储系统，用于共享配置和服务发现（服务注册和查找）。   |
| role           | String | **参数解释** **：** 节点角色。 **取值范围** **：** - master：组件所在节点为主节点。  - slave：组件所在节点为备节点。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| status         | String | **参数解释** **：** 组件状态。 **取值范围** **：** - Primary：该组件为主。  - Normal：该组件状态正常。  - Down：该组件处于宕机状态。  - Standby：该组件为备。  - StateFollower：该ETCD为备。  - StateLeader：该ETCD为主。  - StateCandidate：该ETCD为仲裁。   |
| distributed_id | String | **参数解释** **：** 分组ID，只有DN组件有分组DN，用于区分是否是同一个分片下的组件。其他组件为空字符串。 **取值范围** **：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| type           | String | **参数解释** **：** 节点类型。 **取值范围** **：** - DN：DN类型。  - CN：CN类型。  - GTM：GTM类型。  - CM：CMS类型。  - ETCD：ETCD类型。                                                                                                                                                                                                                                                                              |
| detail         | String | **参数解释** **：** 组件详情。 **取值范围** **：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
   
#### 请求示例
查询实例的组件列表。
```
GET https://gaussdb-opengauss.cn-north-1.myhuaweicloud.com/v3/0483b6b16e954cb88930a360d2c4e663/instances/dd93e98e103b4fc4b5a978a6bd6f03a9in14/components
```
#### 响应示例
查询集中式版实例组件列表。
```
{
    "nodes": [
        {
            "components": [
                {
                    "id": "cm_1",
                    "role": "master",
                    "status": "Primary",
                    "distributed_id": "",
                    "type" : "CM", 
                    "detail" : "" 
                },
                {
                    "id": "etcd_7001",
                    "role": "master",
                    "status": "StateLeader",
                    "distributed_id": "",
                    "type" : "ETCD", 
                    "detail" : "" 
                },
                {
                    "id": "dn_6001",
                    "role": "master",
                    "status": "Primary",
                    "distributed_id": "60011",
                    "type" : "DN", 
                    "detail" : "Normal" 
                }
            ],
            "id": "7d19f72f8f514564bd92962a6fbddb7dno14",
            "name": "gauss-9e1a_root_0",
            "availability_zone_id": "cn-southwest-244a",
            "description": "az1",
            "status": "normal"
        },
        {
            "components": [
                {
                    "id": "cm_3",
                    "role": "slave",
                    "status": "Standby",
                    "distributed_id": "",
                    "type" : "CM", 
                    "detail" : "" 
                },
                {
                    "id": "etcd_7003",
                    "role": "slave",
                    "status": "StateFollower",
                    "distributed_id": "",
                    "type" : "ETCD", 
                    "detail" : "" 
                },
                {
                    "id": "dn_6003",
                    "role": "slave",
                    "status": "Standby",
                    "distributed_id": "60011",
                    "type" : "DN", 
                    "detail" : "Normal" 
                }
            ],
            "id": "aafc2e14234d4c9eadb481fb0a09a865no14",
            "name": "gauss-9e1a_root_2",
            "availability_zone_id": "cn-southwest-244a",
            "description": "az1",
            "status": "normal"
        },
        {
            "components": [
                {
                    "id": "cm_2",
                    "role": "slave",
                    "status": "Standby",
                    "distributed_id": "",
                    "type" : "CM", 
                    "detail" : "" 
                },
                {
                    "id": "etcd_7002",
                    "role": "slave",
                    "status": "StateFollower",
                    "distributed_id": "",
                    "type" : "ETCD", 
                    "detail" : "" 
                },
                {
                    "id": "dn_6002",
                    "role": "slave",
                    "status": "Standby",
                    "distributed_id": "60011",
                    "type" : "DN", 
                    "detail" : "Normal" 
                }
            ],
            "id": "d6c6c6e6b48c41d79d99d7240751d744no14",
            "name": "gauss-9e1a_root_1",
            "availability_zone_id": "cn-southwest-244a",
            "description": "az1",
            "status": "normal"
        }
    ],
    "total_count": 3
}
```
查询分布式独立部署实例组件列表。
```
{
    "nodes": [
        {
            "components": [
                {
                    "id": "cn_5001",
                    "role": "master",
                    "status": "Normal",
                    "distributed_id": "",
                    "type": "CN",
                    "detail": ""
                }
            ],
            "id": "e0c39a9b9e91421cacbfbf75c47e0c9dno14",
            "name": "gauss-6b36_gaussdbv5cn_0",
            "availability_zone_id": "cn-southwest-244a",
            "description": "az1",
            "status": "normal"
        },
        {
            "components": [
                {
                    "id": "gtm_1002",
                    "role": "slave",
                    "status": "Standby",
                    "distributed_id": "",
                    "type": "GTM",
                    "detail": "Connection ok"
                }
            ],
            "id": "a19a1844ab93407489d8a63ca298f908no14",
            "name": "gauss-6b36_gaussdbv5gtm_0",
            "availability_zone_id": "cn-southwest-244a",
            "description": "az1",
            "status": "normal"
        },
        {
            "components": [
                {
                    "id": "gtm_1003",
                    "role": "slave",
                    "status": "Standby",
                    "distributed_id": "",
                    "type": "GTM",
                    "detail": "Connection ok"
                }
            ],
            "id": "fd949ad6b00c4d72b7af5f015817d4d9no14",
            "name": "gauss-6b36_gaussdbv5gtm_1",
            "availability_zone_id": "cn-southwest-244b",
            "description": "az2",
            "status": "normal"
        },
        {
            "components": [
                {
                    "id": "cm_2",
                    "role": "slave",
                    "status": "Standby",
                    "distributed_id": "",
                    "type": "CM",
                    "detail": ""
                },
                {
                    "id": "etcd_7002",
                    "role": "slave",
                    "status": "StateFollower",
                    "distributed_id": "",
                    "type": "ETCD",
                    "detail": ""
                }
            ],
            "id": "ac7e24fc9626479c96ab6215f2107faeno14",
            "name": "gauss-6b36_gaussdbv5cms_1",
            "availability_zone_id": "cn-southwest-244b",
            "description": "az2",
            "status": "normal"
        },
        {
            "components": [
                {
                    "id": "dn_6001",
                    "role": "master",
                    "status": "Primary",
                    "distributed_id": "60011",
                    "type": "DN",
                    "detail": "Normal"
                }
            ],
            "id": "0989068696f94631a45b3f2b13ac7810no14",
            "name": "gauss-6b36_gaussdbv5dn1_0",
            "availability_zone_id": "cn-southwest-244a",
            "description": "az1",
            "status": "normal"
        },
        {
            "components": [
                {
                    "id": "cm_1",
                    "role": "master",
                    "status": "Primary",
                    "distributed_id": "",
                    "type": "CM",
                    "detail": ""
                },
                {
                    "id": "etcd_7001",
                    "role": "master",
                    "status": "StateFollower",
                    "distributed_id": "",
                    "type": "ETCD",
                    "detail": ""
                }
            ],
            "id": "912ca1f9f12f41968d60d82a7f630bedno14",
            "name": "gauss-6b36_gaussdbv5cms_2",
            "availability_zone_id": "cn-southwest-244c",
            "description": "az3",
            "status": "normal"
        },
        {
            "components": [
                {
                    "id": "dn_6002",
                    "role": "slave",
                    "status": "Standby",
                    "distributed_id": "60011",
                    "type": "DN",
                    "detail": "Normal"
                }
            ],
            "id": "365261e60ac14dff846480e8cc555d66no14",
            "name": "gauss-6b36_gaussdbv5dn1_1",
            "availability_zone_id": "cn-southwest-244b",
            "description": "az2",
            "status": "normal"
        },
        {
            "components": [
                {
                    "id": "dn_6003",
                    "role": "slave",
                    "status": "Standby",
                    "distributed_id": "60011",
                    "type": "DN",
                    "detail": "Normal"
                }
            ],
            "id": "3ce7e13a25524e7b81d78cad9afd9464no14",
            "name": "gauss-6b36_gaussdbv5dn1_2",
            "availability_zone_id": "cn-southwest-244c",
            "description": "az3",
            "status": "normal"
        },
        {
            "components": [
                {
                    "id": "cm_3",
                    "role": "slave",
                    "status": "Standby",
                    "distributed_id": "",
                    "type": "CM",
                    "detail": ""
                },
                {
                    "id": "etcd_7003",
                    "role": "slave",
                    "status": "StateLeader",
                    "distributed_id": "",
                    "type": "ETCD",
                    "detail": ""
                }
            ],
            "id": "e0deb77337604d149a76ce02b5060d86no14",
            "name": "gauss-6b36_gaussdbv5cms_0",
            "availability_zone_id": "cn-southwest-244a",
            "description": "az1",
            "status": "normal"
        },
        {
            "components": [
                {
                    "id": "gtm_1001",
                    "role": "master",
                    "status": "Primary",
                    "distributed_id": "",
                    "type": "GTM",
                    "detail": "Connection ok"
                }
            ],
            "id": "9a88dc2a3f3e4f8c844f86dc032fde84no14",
            "name": "gauss-6b36_gaussdbv5gtm_2",
            "availability_zone_id": "cn-southwest-244c",
            "description": "az3",
            "status": "normal"
        }
    ],
    "total_count": 10
}
```
#### 状态码
- 正常 200
  
- 异常 请参见[状态码](https://support.huaweicloud.com/api-gaussdb/gaussdb_api_194.html)。
  
 
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-gaussdb/gaussdb_api_195.html)。
