OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

Kubernetes operator for OceanBase

V2.3.1Community Edition

  • Overview
  • Quick start
  • Deploy
  • Upgrade
  • User guide
    • Cluster management
      • Manage clusters
      • Create a cluster
      • Zone management
        • Add zones to a cluster
        • Delete zones from a cluster
      • Server management
        • Add OBServer nodes to zones
        • Delete OBServer nodes from zones
      • Upgrade a cluster
      • Manage parameters
      • Update resources
      • Delete a cluster
    • Tenant management
      • Manage tenants
      • Create a tenant
      • Modify tenant
        • Manage resources
        • Manage replicas
        • Modify other parameters
      • Delete a tenant
      • Perform tenant O&M operations
    • High availability
      • High availability
      • Recover from node failure
      • Back up a tenant
      • Restore data from a backup
      • Physical standby tenant
      • Inter K8s cluster management
  • Configure
  • Appendix
    • Deploy OceanBase Database and web app in a Kubernetes cluster
    • FAQ
  • Changelog

Download PDF

Overview Quick start Deploy Upgrade Manage clusters Create a cluster Upgrade a cluster Manage parameters Update resources Delete a cluster Manage tenants Create a tenant Delete a tenant Perform tenant O&M operations High availability Recover from node failure Back up a tenant Restore data from a backup Physical standby tenant Inter K8s cluster management Configure Deploy OceanBase Database and web app in a Kubernetes cluster FAQ Changelog
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. Kubernetes operator for OceanBase
  3. V2.3.1
iconKubernetes operator for OceanBase
V 2.3.1Community Edition
Community Edition
  • V 2.3.1
  • V 2.3.0
  • V 2.2.0
  • V 2.1.2
  • V 2.1.1
  • V 2.1.0

Create a tenant

Last Updated:2025-11-28 06:07:04  Updated
share
What is on this page
Prerequisites
Create a tenant by using the configuration file
Example
Verify whether the tenant is created
What to do next

folded

share

This topic describes how to create a tenant by using ob-operator.

Prerequisites

Before you create a tenant, make sure the following conditions are met:

  • You have deployed ob-operator V2.1.0 or later.

  • You have deployed an OceanBase cluster, which is running normally.

Create a tenant by using the configuration file

You can create a tenant by using the configuration file of the tenant. For more information about the configuration file, visit GitHub.

Run the following command to create a tenant. This command creates an OceanBase Database tenant with custom resources in the current Kubernetes cluster.

kubectl apply -f tenant.yaml

Example

Create a MySQL tenant named t1 with three replicas and allow all clients to connect to the tenant.

During the creation of the tenant, ob-operator creates resource units and resource pools based on the zones in the pools specified in the tenant.yaml configuration file. ob-operator creates resource units based on the parameter settings in the resource section and creates resource pools based on the resource units.

apiVersion: oceanbase.oceanbase.com/v1alpha1  
kind: OBTenant  
metadata:  
  name: t1
  namespace: oceanbase
spec:
  obcluster: obcluster
  tenantName: t1
  unitNum: 1
  charset: utf8mb4  
  connectWhiteList: '%'
  forceDelete: true
  credentials: # optional
    root: t1-ro # optional, empty root password if not given
    standbyRo: t1-ro # optional, generate automatically if not given
  pools:
    - zone: zone1
      type:
        name: Full
        replica: 1
        isActive: true
      resource:
        maxCPU: 1
        minCPU: 1
        memorySize: 5Gi
        maxIops: 1024
        minIops: 1024
        iopsWeight: 2
        logDiskSize: 12Gi
    - zone: zone2
      type:
        name: Full
        replica: 1
        isActive: true
      resource:
        maxCPU: 1
        minCPU: 1
        memorySize: 5Gi
        maxIops: 1024
        minIops: 1024
        iopsWeight: 2
        logDiskSize: 12Gi
    - zone: zone3
      type:
        name: Full
        replica: 1
        isActive: true
      priority: 3
      resource:
        maxCPU: 1
        minCPU: 1
        memorySize: 5Gi
        maxIops: 1024
        minIops: 1024
        iopsWeight: 2
        logDiskSize: 12Gi

The following table describes the parameters.

Parameter Description
metadata.name Required. The name of the tenant resource, which must be unique in the same namespace of the Kubernetes cluster.
metadata.namespace Required. The namespace where the tenant resources are located.
obcluster Required. The name of the OceanBase cluster in which the tenant is to be created.
tenantName Required. The name of the tenant. Like a variable, a tenant name can contain up to 128 characters, which can be letters, digits, and underscores (_). The tenant name must start with a letter or an underscore (_) and cannot be a keyword of OceanBase Database. For more information about the keywords supported by OceanBase Database, see Reserved keywords (MySQL mode) or Reserved keywords (Oracle mode).
unitNum Required. The number of resource units to be created for the zone. The value must be less than the number of OBServer nodes in the zone.
charset Optional. The character set of the tenant. For more information about character sets, see Character sets. This parameter is set to utf8mb4 by default.
collate Optional. The collation of the tenant. For more information about collations, see Collations.
connectWhiteList Optional. The IP addresses of the clients that are allowed to connect to the tenant. % indicates that all client IP addresses are allowed to connect to the tenant. The default value is %. When you modify this parameter, the value must include the CIDR block of ob-operator; otherwise, ob-operator cannot connect to the tenant.
forceDelete Optional. Specifies whether to forcibly delete the tenant. The default value is false.
credentials Optional. The secret resources referenced for creating the user and changing the password when you create the tenant. You can specify the passwords of the root account and the standbyro account. If you do not specify this parameter, the password is not changed.
pools The topology of the tenant, which defines the replica and resource distribution of the tenant in each zone.
type.name Required. The type of replicas in the zone. The valid values are full and readonly. This parameter is case insensitive.
type.replica Optional. The number of replicas in the zone. This parameter is set to 1 by default.
type.isActive Specifies whether to enable the zone.
priority Optional. The priority of the current zone. A larger number indicates a higher priority. This parameter is set to 0 by default.
resource The resource information of the tenant in the zone.
maxCPU Required. The maximum number of CPU cores provided by a resource unit in the zone for the tenant. The minimum value is 1.
minCPU Optional. The minimum number of CPU cores provided by a resource unit in the zone for the tenant. This parameter is equal to the value of the maxCPU parameter by default.
memorySize Required. The size of memory provided by a resource unit in the zone for the tenant. The minimum value is 1GB. Take note of the value of the cluster parameter __min_full_resource_pool_memory when you specify this parameter.
maxIops Optional. The maximum I/O resources provided by a resource unit in the zone for the tenant.
minIops Optional. The minimum I/O resources provided by a resource unit in the zone for the tenant.
iopsWeight Optional. The weight of the tenant for using I/O resources provided by a resource unit in the zone. The default value is 1.
logDiskSize Optional. The size of log space provided by a resource unit in the zone for the tenant. The default value is three times the memory size. The minimum value is 2Gi.

Verify whether the tenant is created

After the tenant creation process is completed, run the following command to check whether the current Kubernetes cluster contains the custom resources of the created tenant and whether the status of the custom resource is Running. The related configurations are displayed in the status section.

kubectl describe obtenants.oceanbase.oceanbase.com -n oceanbase t1

Here is a sample result:

Name:         t1
Namespace:    oceanbase
Labels:       <none>
Annotations:  <none>
API Version:  oceanbase.oceanbase.com/v1alpha1
Kind:         OBTenant
Metadata:
  Creation Timestamp:  2023-11-13T07:28:31Z
  Finalizers:
    finalizers.oceanbase.com.deleteobtenant
  Generation:        2
  Resource Version:  940236
  UID:               34036a49-26bf-47cf-8201-444b3850aaa2
Spec:
  Charset:             utf8mb4
  Connect White List:  %
  Credentials:
    Root:        t1-ro
    Standby Ro:  t1-ro
  Force Delete:  true
  Obcluster:     obcluster
  Pools:
    Priority:  1
    Resource:
      Iops Weight:    2
      Log Disk Size:  12Gi
      Max CPU:        1
      Max Iops:       1024
      Memory Size:    5Gi
      Min CPU:        1
      Min Iops:       1024
    Type:
      Is Active:  true
      Name:       Full
      Replica:    1
    Zone:         zone1
    Priority:     1
    Resource:
      Iops Weight:    2
      Log Disk Size:  12Gi
      Max CPU:        1
      Max Iops:       1024
      Memory Size:    5Gi
      Min CPU:        1
      Min Iops:       1024
    Type:
      Is Active:  true
      Name:       Full
      Replica:    1
    Zone:         zone2
    Priority:     3
    Resource:
      Iops Weight:    2
      Log Disk Size:  12Gi
      Max CPU:        1
      Max Iops:       1024
      Memory Size:    5Gi
      Min CPU:        1
      Min Iops:       1024
    Type:
      Is Active:  true
      Name:       Full
      Replica:    1
    Zone:         zone3
  Tenant Name:    t1
  Tenant Role:    PRIMARY
  Unit Num:       1
Status:
  Credentials:
    Root:        t1-ro
    Standby Ro:  t1-ro
  Resource Pool:
    Priority:  1
    Type:
      Is Active:  true
      Name:       FULL
      Replica:    1
    Unit Config:
      Iops Weight:    2
      Log Disk Size:  12884901888
      Max CPU:        1
      Max Iops:       1024
      Memory Size:    5368709120
      Min CPU:        1
      Min Iops:       1024
    Unit Num:         1
    Units:
      Migrate:
        Server IP:    
        Server Port:  0
      Server IP:      10.42.0.189
      Server Port:    2882
      Status:         ACTIVE
      Unit Id:        1006
    Zone List:        zone1
    Priority:         1
    Type:
      Is Active:  true
      Name:       FULL
      Replica:    1
    Unit Config:
      Iops Weight:    2
      Log Disk Size:  12884901888
      Max CPU:        1
      Max Iops:       1024
      Memory Size:    5368709120
      Min CPU:        1
      Min Iops:       1024
    Unit Num:         1
    Units:
      Migrate:
        Server IP:    
        Server Port:  0
      Server IP:      10.42.1.118
      Server Port:    2882
      Status:         ACTIVE
      Unit Id:        1007
    Zone List:        zone2
    Priority:         2
    Type:
      Is Active:  true
      Name:       FULL
      Replica:    1
    Unit Config:
      Iops Weight:    2
      Log Disk Size:  12884901888
      Max CPU:        1
      Max Iops:       1024
      Memory Size:    5368709120
      Min CPU:        1
      Min Iops:       1024
    Unit Num:         1
    Units:
      Migrate:
        Server IP:    
        Server Port:  0
      Server IP:      10.42.0.190
      Server Port:    2882
      Status:         ACTIVE
      Unit Id:        1008
    Zone List:        zone3
  Status:             running
  Tenant Record Info:
    Charset:             utf8mb4
    Connect White List:  %
    Locality:            FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3
    Pool List:           pool_t1_zone1,pool_t1_zone2,pool_t1_zone3
    Primary Zone:        zone3;zone1,zone2
    Tenant ID:           1006
    Unit Num:            1
    Zone List:           zone1,zone2,zone3
  Tenant Role:           PRIMARY
Events:
  Type    Reason  Age                    From                 Message
  ----    ------  ----                   ----                 -------
  Normal          2m58s                  obtenant-controller  start creating
  Normal          115s                   obtenant-controller  create OBTenant successfully

What to do next

After the tenant is created, the password of its administrator account is the value of secret specified in the spec.credentials.root field. If you have not specified the secret field, the password is empty. You can use the obclient -h${podIP} -P2881 -uroot@tenantname -p -A or mysql -h${podIP} -P2881 -uroot@tenantname -p -A statement to log on to the database.

Previous topic

Manage tenants
Last

Next topic

Manage resources
Next
What is on this page
Prerequisites
Create a tenant by using the configuration file
Example
Verify whether the tenant is created
What to do next