This topic describes how to manage tenant replicas by using ob-operator.
Prerequisites
ob-operator V1.2.0-snapshot or later is deployed.
OceanBase Database is deployed and runs normally.
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
Modify the tenant configuration file
tenant.yamlto adjust the priority value for each zone.- zone: zone1 priority: 1 - zone: zone2 @priority 2 - zone: zone3 priority: 3 # After modification - zone: zone1 priority: 3 - zone: zone2 @priority 2 - zone: zone3 priority: 1The preceding configuration changes the primary zone of the tenant from
zone3;zone2;zone1tozone1;zone2;zone3.Run the following command for the modification to take effect:
kubectl apply -f tenant.yamlRun the following command to view the custom resource of the tenant in the current Kubernetes cluster to determine whether the modification is successful:
kubectl get tenant -A -o yamlIf the priority values in the
statussection in the custom resource of the tenant are changed to the new values, the modification is successful.status: ... topology: - zone: zone1 priority: 3 - zone: zone2 @priority 2 - zone: zone3 priority: 1Note
The
priorityvalues in thestatussection can differ from those in thespecsection, provided that they denote the same priority order.
For example,zone1:1, zone2:1, zone3:2andzone1:1, zone2:1, zone3:3indicate the same priority order, which iszone3; zone1, zone2;.
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 below.
Modify the tenant configuration file tenant.yaml:
type:
name: Full
replica: 1
Add replicas
Prerequisites
- You have added zones 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 five zones, zone1, zone2, zone3, zone4, and zone5, the zones corresponding to the tenant are zone1, zone2, and zone3, and you want to scale out the tenant to five zones.
Modify the configuration file
tenant.yamlto addzone4andzone5.# For example, the tenant has three zones. topology: - zone: zone1 unitNum: 1 type: name: FUll replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 3Gi maxSessionNum: 512 # v4 iopsWeight: logDiskSize: - zone: zone2 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4Gi - zone: zone3 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4Gi # Add zone4 and zone5 to the tenant. topology: - zone: zone1 unitNum: 1 type: name: FUll replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 3Gi maxSessionNum: 512 # v4 iopsWeight: logDiskSize: - zone: zone2 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4Gi - zone: zone3 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4Gi - zone: zone4 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4Gi - zone: zone5 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4GiRun the following command for the modification to take effect:
kubectl apply -f tenant.yamlRun the following command to view the custom resource of the tenant in the current Kubernetes cluster:
kubectl get tenant -A -o yaml
Remove replicas
Procedure
You can modify the tenant configuration file tenant.yaml to remove zones from a tenant.
Assume that the current cluster has five zones, zone1, zone2, zone3, zone4, and zone5, the tenant corresponds to zone1, zone2, zone3, zone4, and zone5, and you want to scale in the tenant so that the tenant contains only zone1, zone2, and zone3.
Modify the
tenant.yamlconfiguration file to removezone4andzone5.# For example, the tenant has five zones. topology: - zone: zone1 unitNum: 1 type: name: FUll replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 3Gi maxSessionNum: 512 # v4 iopsWeight: logDiskSize: - zone: zone2 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4Gi - zone: zone3 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4Gi - zone: zone4 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4Gi - zone: zone5 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4Gi # Remove zone4 and zone5 from the tenant. topology: - zone: zone1 unitNum: 1 type: name: FUll replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 3Gi maxSessionNum: 512 # v4 iopsWeight: logDiskSize: - zone: zone2 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4Gi - zone: zone3 unitNum: 1 type: name: Full replica: 1 priority: 3 resource: maxCPU: 2500m memorySize: 1Gi # Optional minCPU: 2 maxIops: 1024 minIops: 1024 # v3 maxDiskSize: 1Gi maxSessionNum: 64 # v4 iopsWeight: 2 logDiskSize: 4GiRun the following command for the modification to take effect:
kubectl apply -f tenant.yamlRun the following command to view the custom resource of the tenant in the current Kubernetes cluster:
kubectl get tenant -A -o yaml