---
title: "创建租户 - OceanBase 数据库 V4.3.4 | OceanBase 文档中心"
description: 创建租户 本文介绍如何通过 obshell-sdk-go 创建租户。 说明 建议先查看 obshell-sdk-go 快速上手 内容，了解如何使用 obshell-sdk-go。 注意事项 请确保 obshell 正常运行。 请求的 client 对应的节点需在已初始化的集群中。 示例代码 任务同步执行 任务异步执行…
---
切换语言

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

文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*P8CuR4UJ_FkAAAAAAAAAAAAADiGDAQ/original) OceanBase 数据库分布式版 - V 4.3.4

# 创建租户

更新时间：2025-09-08 10:42:50

[编辑](https://github.com/oceanbase/oceanbase-doc/edit/V4.3.4/zh-CN/700.reference/1500.Components-and-Tools/100.manage/100.obshell/500.obshell-sdk-reference/200.go/500.tenant-management/100.create-tenant-of-go.md)  

本文介绍如何通过 obshell-sdk-go 创建租户。

#### 说明

建议先查看 [obshell-sdk-go 快速上手](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000001577529) 内容，了解如何使用 obshell-sdk-go。

## 注意事项

- 请确保 obshell 正常运行。
 - 请求的 client 对应的节点需在已初始化的集群中。

## 示例代码

    任务同步执行   任务异步执行

```go
package main

import (
  "fmt"

  "github.com/oceanbase/obshell-sdk-go/services"
  "github.com/oceanbase/obshell-sdk-go/services/v1"
)

func main() {
  // 创建 client 实例，节点地址为 '10.10.10.1'，端口为 2886。
  client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
  if err != nil {
    fmt.Print(err)
    return
  }

  req := client.V1().NewCreateTenantRequest("t1", []v1.ZoneParam{
    {
      Name:           "zone1",
      ReplicaType:    "FULL",
      UnitConfigName: "s1",
      UnitNum:        1,
    },
  })

  if _, err = client.V1().CreateTenantSyncWithRequest(req); err != nil {
    fmt.Print(err)
    return
  }
}

```

  dag, err := client.V1().CreateTenantWithRequest(req)
  if err != nil {
    fmt.Print(err)
    return
  }

  // 等待任务成功。
  if _, err = client.V1().WaitDagSucceed(dag.GenericID); err != nil {
    fmt.Print(err)
    return
  }
}

```

## 相关文档

- 创建租户的 API 接口说明可参见 [创建租户](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000001577473)。
 - 通过 obshell-sdk-python 请求 API 方法的介绍可参见 [创建租户](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000001578557)。

 上一篇 下一篇 ![有帮助](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) 咨询热线
