OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

Kubernetes operator for OceanBase

V2.3.4Community 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

Document Feedback
  1. Documentation Center
  2. Kubernetes operator for OceanBase
  3. V2.3.4

Manage replicas

Last Updated:2026-09-04 08:21:43

Modify the primary zone of a tenant
Procedure
Modify the locality of a tenant
Add replicas
Prerequisites
Procedure
Delete replicas
Procedure

This topic describes how to manage tenant replicas by using ob-operator.

Modify the primary zone of a tenant

You can modify the priority parameter of zones in the tenant configuration file to modify the primary zone of a tenant. A larger number indicates a higher priority. The minimum value is 1.

The primary zone describes the preferred location of the leader. The leader handles strong-consistency read traffic and write traffic of the business. Therefore, the primary zone determines the traffic distribution of OceanBase Database. You can modify the primary zone to switch business traffic from one IDC to another or from one city to another in disaster recovery and scaling scenarios.

Procedure

  1. Modify the tenant configuration file tenant.yaml to adjust the priority value for each zone.

    - zone: zone1
      priority: 1
    - zone: zone2
      priority: 1
    - zone: zone3
      priority: 3
    
    # After modification
    - zone: zone1
      priority: 3
    - zone: zone2
      @priority 2
    - zone: zone3
      priority: 1
    

    The preceding configuration changes the primary zone of the tenant from zone3;zone1,zone2 to zone1;zone2;zone3.

  2. Run the following command for the modification to take effect:

    kubectl apply -f tenant.yaml
    
  3. Run the following command to view the custom resources of the tenant in the current Kubernetes cluster to check whether the modification is successful:

    kubectl get obtenants.oceanbase.oceanbase.com -n oceanbase -o yaml
    

    If the value of the corresponding parameter in the status.resourcePool.priority section in the custom resources of the tenant is changed to the new value, the modification is successful.

    status:
      ...
      resourcePool:
        - zone: zone1
          priority: 3
        - zone: zone2
          @priority 2
        - zone: zone3
          priority: 1
    

    You can also run the following command to view the result.

    kubectl get obtenants.oceanbase.oceanbase.com -n oceanbase -o wide
    

    The command output is as follows:

    NAME   STATUS    TENANTNAME   TENANTROLE   CLUSTERNAME   AGE   LOCALITY   PRIMARYZONE           POOLLIST    CHARSET
    t1     running   t1           PRIMARY      obcluster     13m   ...        zone1;zone2;zone3     ...         utf8mb4
    

    The result shows that the value of the PRIMARYZONE field is modified to zone1;zone2;zone3, which matches the priority configuration.

Modify the locality of a tenant

To modify the locality of a tenant, you can modify the parameters in the type section to specify the replica type and the number of replicas. The following replica types are supported: full, logonly, and readonly.

For more information, see Modify the primary zone of a tenant.

Modify the tenant configuration file tenant.yaml:

 type:
    name: Full # The Full and Readonly replica types are supported.
    replica: 1

Add replicas

Prerequisites

  • You have added a zone to the cluster. For more information, see Add zones to a cluster.

Procedure

You can add zones to a tenant by modifying the tenant configuration file tenant.yaml.

Assume that the current cluster has four zones, zone1, zone2, zone3, and zone4, the zones corresponding to the tenant are zone1, zone2, and zone3, and you want to scale out the tenant to four zones.

  1. Modify the configuration file tenant.yaml to add zone4.

    # For example, the tenant has three zones.
    pools:
      - zone: zone1
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
      - zone: zone2
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
      - zone: zone3
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
    
    # Add zone4 to the tenant.
    pools:
      - zone: zone1
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
      - zone: zone2
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
      - zone: zone3
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
      - zone: zone4
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
    
  2. Run the following command for the modification to take effect:

    kubectl apply -f tenant.yaml
    
  3. Run the following command to view the custom resources of the tenant in the current Kubernetes cluster:

    kubectl get obtenants.oceanbase.oceanbase.com -n oceanbase -o wide
    

    The following command output shows that the value of the LOCALITY field is as expected:

    NAME   STATUS    TENANTNAME   TENANTROLE   CLUSTERNAME   AGE   LOCALITY                                                       PRIMARYZONE           POOLLIST    CHARSET
    t1     running   t1           PRIMARY      obcluster     19m   FULL{1}@zone1,FULL{1}@zone2,FULL{1}@zone3,FULL{1}@zone4        ...                   ...         utf8mb4
    

Delete replicas

Procedure

You can modify the tenant configuration file tenant.yaml to delete zones from a tenant.

Assume that the current cluster has four zones, zone1, zone2, zone3, and zone4, the zones corresponding to the tenant are zone1, zone2, zone3, and zone4, and you want to scale in the tenant to zone1, zone2, and zone3.

  1. Modify the configuration file tenant.yaml to delete zone4.

    # For example, the tenant has four zones.
    pools:
      - zone: zone1
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
      - zone: zone2
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
      - zone: zone3
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
      - zone: zone4
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
    
    # Delete zone4 from the tenant.
    pools:
      - zone: zone1
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
      - zone: zone2
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
      - zone: zone3
        unitNum: 1
        type:
          name: Full
          replica: 1
        priority: 3
        resource:
          ...
    
  2. Run the following command for the modification to take effect:

    kubectl apply -f tenant.yaml
    
  3. Run the following command to view the custom resources of the tenant in the current Kubernetes cluster:

    kubectl get obtenants.oceanbase.oceanbase.com -n oceanbase -o wide
    

    The following command output shows that the value of the LOCALITY field is as expected:

    NAME   STATUS    TENANTNAME   TENANTROLE   CLUSTERNAME   AGE   LOCALITY                                     PRIMARYZONE     POOLLIST    CHARSET
    t1     running   t1           PRIMARY      obcluster     25m   FULL{1}@zone1,FULL{1}@zone2,FULL{1}@zone3    ...             ...         utf8mb4
    

Previous topic

Manage resources
Last

Next topic

Modify other parameters
Next
on this page
Modify the primary zone of a tenant
Procedure
Modify the locality of a tenant
Add replicas
Prerequisites
Procedure
Delete replicas
Procedure