---
title: "创建 OceanBase 集群 | OceanBase 文档中心"
description: 创建 OceanBase 集群 功能说明 该接口用于创建 OceanBase 集群。 调用说明 接口约束 调用者需具备创建 OceanBase 集群的权限。 关于调用者的权限，详情可参见 安全概述 。 调用者需要通过 OCP 应用服务鉴权。 请求路径 POST /api/v2/ob/clusters 请求参数 参数 …
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*lJTmRZ61jSUAAAAAAAAAAAAADiGDAQ/original) 云平台 OCPV 4.0.3 企业版

# 创建 OceanBase 集群

更新时间：2023-08-16 15:51:32

## 功能说明

该接口用于创建 OceanBase 集群。

## 调用说明

### 接口约束

- 调用者需具备创建 OceanBase 集群的权限。

  关于调用者的权限，详情可参见 [安全概述](https://www.oceanbase.com/docs/enterprise-oceanbase-ocp-cn-10000000001538756)。
 - 调用者需要通过 OCP 应用服务鉴权。

### 请求路径

`POST /api/v2/ob/clusters`

### 请求参数

| 参数 | 类型 | 必选 | 示例值 | 描述 |
| --- | --- | --- | --- | --- |
| name | String | 是 | foo | 集群名。 |
| rpmName | String | 是 | oceanbase-2.2.76-20210219154519.el7.x86_64.rpm | rpm 包名。 |
| type | String | 是 | PRIMARY | 集群类型，取值范围： * PRIMARY * STANDBY |
| password | String | 是 | bar | 为集群指定 sys 租户中 root 账号的密码。 |
| zones | Object | 是 | -- | -- |
| ├─name | String | 是 | zone1 | Zone 名。 |
| ├─idcName | String | 是 | idc1 | 机房名。 |
| ├─servers | Array | 是 | [1,2] | 主机 ID 列表。 |

### 返回结果

基础数据结构

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| data | Object | 异步任务信息，详情参见 [任务信息](https://www.oceanbase.com/docs/enterprise-oceanbase-ocp-cn-10000000001540216)。 |
| successful | Boolean | 请求是否成功。 |
| timestamp | Datetime | 服务端完成请求的时间戳。 |
| duration | Integer | 服务端处理请求的时间（毫秒）。 |
| status | Integer | 符合 HTTP Status 规范的编码。 |
| traceId | String | 请求的 Trace ID，用于排查问题。 |
| server | String | 响应请求的应用服务的地址。 |

## 示例

### 请求示例

`POST /api/v2/ob/clusters`

body:

```unknow
{
  "type": "PRIMARY",
  "name": "terran",
  "password": "xxxxx",
  "primaryZone": "",
  "rpmName": "oceanbase-2.2.73-20201211175814.el7.x86_64.rpm",
  "zones": [
    {
      "name": "zone1",
      "idcName": "hz2",
      "servers": [
        1
      ]
    }
  ]
}

```

### 返回示例

```unknow
{
  "data": {
    "cluster": {
      "id": 22,
      "name": "terran",
      "obClusterId": 1
    },
    "context": "Context(parallelIdx=-1, stringMap={cluster_version=2.2.73, cluster_name=terran, startup_option_string=system_memory=5G, ob_version=2.2.73, service_name=terran:1, ob_connect_address=xxx.xxx.xxx.xxx, cluster_type=PRIMARY, ob_cluster_id=1, link_obproxy=false, zone1.idc=hz2, primary_zone=, sql_port=2881, service_type=OB_CLUSTER, cluster_id=22, rpm_name=oceanbase-2.2.73-20201211175814.el7.x86_64.rpm, target_cluster_status=RUNNING}, listMap={root_servers=[1], root_server_ips=[xxx.xxx.xxx.xxx], host_ids=[1], zone1.host_ids=[1], zone_names=[zone1]})",
    "creator": {
      "id": 100,
      "name": "admin"
    },
    "id": 108088,
    "name": "Create primary OB cluster",
    "startTime": "2021-03-02T11:39:34.508+08:00",
    "status": "RUNNING",
    "tasks": [
      {
        "description": "Trigger compaction",
        "downstreams": [
          129864
        ],
        "id": 129848,
        "name": "Trigger compaction",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129859
        ]
      },
      {
        "description": "Set sys primary zone",
        "downstreams": [
          129855
        ],
        "id": 129849,
        "name": "Set sys primary zone",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129850
        ]
      },
      {
        "description": "Create default user",
        "downstreams": [
          129849
        ],
        "id": 129850,
        "name": "Create default user",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129866
        ]
      },
      {
        "description": "Wait node",
        "downstreams": [
          129865
        ],
        "id": 129851,
        "name": "Wait node",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129853
        ]
      },
      {
        "description": "Wait node",
        "downstreams": [
          129870
        ],
        "id": 129852,
        "name": "Wait node",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129867
        ]
      },
      {
        "description": "Make dir for ob",
        "downstreams": [
          129851
        ],
        "id": 129853,
        "name": "Make dir for ob",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129868
        ]
      },
      {
        "description": "Wait node",
        "downstreams": [
          129869
        ],
        "id": 129854,
        "name": "Wait node",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129862
        ]
      },
      {
        "description": "Wait cluster accessible",
        "downstreams": [
          129867
        ],
        "id": 129855,
        "name": "Wait cluster accessible",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129849
        ]
      },
      {
        "description": "Sync all tenant information",
        "downstreams": [
          129859
        ],
        "id": 129856,
        "name": "Sync all tenant information",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129857
        ]
      },
      {
        "description": "Sync cluster info",
        "downstreams": [
          129856
        ],
        "id": 129857,
        "name": "Sync cluster info",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129870
        ]
      },
      {
        "description": "Prepare install cluster",
        "downstreams": [
          129862
        ],
        "id": 129858,
        "name": "Prepare install cluster",
        "operation": "EXECUTE",
        "status": "RUNNING",
        "upstreams": [

        ]
      },
      {
        "description": "Update OB cluster status",
        "downstreams": [
          129848
        ],
        "id": 129859,
        "name": "Update OB cluster status",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129856
        ]
      },
      {
        "description": "Restart observer process",
        "downstreams": [
          129861
        ],
        "id": 129860,
        "name": "Restart observer process",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129863
        ]
      },
      {
        "description": "Wait observer accessible",
        "downstreams": [
          129866
        ],
        "id": 129861,
        "name": "Wait observer accessible",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129860
        ]
      },
      {
        "description": "Pre check for install OB",
        "downstreams": [
          129854
        ],
        "id": 129862,
        "name": "Pre check for install OB",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129858
        ]
      },
      {
        "description": "Bootstrap ob",
        "downstreams": [
          129860
        ],
        "id": 129863,
        "name": "Bootstrap ob",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129865
        ]
      },
      {
        "description": "Link obproxy",
        "downstreams": [

        ],
        "id": 129864,
        "name": "Link obproxy",
        "operation": "EXECUTE",
        "status": "PENDING",

 "upstreams": [
          129848
        ]
      },
      {
        "description": "Do io bench",
        "downstreams": [
          129863
        ],
        "id": 129865,
        "name": "Do io bench",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129851
        ]
      },
      {
        "description": "Set sys password",
        "downstreams": [
          129850
        ],
        "id": 129866,
        "name": "Set sys password",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129861
        ]
      },
      {
        "description": "Refresh ocp agent config",
        "downstreams": [
          129852
        ],
        "id": 129867,
        "name": "Refresh ocp agent config",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129855
        ]
      },
      {
        "description": "Wait node",
        "downstreams": [
          129853
        ],
        "id": 129868,
        "name": "Wait node",
        "operation": "EXECUTE",
        "status": "PENDING",

 "upstreams": [
          129869
        ]
      },
      {
        "description": "Install rpm",
        "downstreams": [
          129868
        ],
        "id": 129869,
        "name": "Install rpm",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129854
        ]
      },
      {
        "description": "Start ocp agent service",
        "downstreams": [
          129857
        ],
        "id": 129870,
        "name": "Start ocp agent service",
        "operation": "EXECUTE",
        "status": "PENDING",
        "upstreams": [
          129852
        ]
      }
    ]
  },
  "duration": 446,
  "server": "a83ad33525",
  "status": 200,
  "successful": true,
  "timestamp": "2021-03-02T11:39:34.614+08:00",
  "traceId": "ec3bd39a90c748d4"
}

```

 上一篇 下一篇 ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
