This topic describes how to scale in an OceanBase cluster by deleting OBServer nodes from zones.
Prerequisites
The resources in the cluster are excessive for the current load. For information about how to view the resource details of a cluster in OceanBase Cloud Platform (OCP), see View the resource details of a cluster.
Delete OBServer nodes from zones by using SQL statements
You can use SQL statements to delete OBServer nodes from zones. Generally, you must delete the same number of OBServer nodes from each zone.
For example, assume that you have a cluster that has three zones, which are z1, z2, and z3, and each zone has two OBServer nodes. The cluster has a user tenant named tenant1. The following code shows the resource distribution of the tenant:
obclient> CREATE RESOURCE UNIT unit1 MAX_CPU 6,MIN_CPU 6, MEMORY_SIZE '36G', MAX_IOPS 1024, MIN_IOPS 1024, IOPS_WEIGHT=0, LOG_DISK_SIZE = '2G';
obclient> CREATE RESOURCE POOL pool1 UNIT 'unit1', UNIT_NUM 1, ZONE_LIST ('z1','z2','z3');
obclient>CREATE TENANT tenant1 resource_pool_list=('pool1');
Assume that you need to delete one OBServer node from each zone. After the scale-in, each of the three zones has one OBServer node.
Sample code:
Log on to the
systenant of the cluster as therootuser.Execute the following statement to delete the specified OBServer nodes from zones in the cluster.
Notice
In the current database version, you cannot decrease the value of
UNIT_NUMfor a tenant. The scale-in method mentioned in this topic applies only if the number of resource units in the current cluster is smaller than or equal to the number of available OBServer nodes in each zone after OBServer nodes are deleted as planned. In this example, if the value of theUNIT_NUMparameter is 2 for thetenant1tenant, the operation of deleting OBServer nodes from each zone will fail.In this statement,
xxx.xxx.x.xx1,xxx.xxx.x.xx2, andxxx.xxx.x.xx3are the IP addresses of the OBServer nodes to be deleted.obclient> ALTER SYSTEM DELETE SERVER 'xxx.xxx.x.xx1:2882' ZONE='z1'; obclient> ALTER SYSTEM DELETE SERVER 'xxx.xxx.x.xx2:2882' ZONE='z2'; obclient> ALTER SYSTEM DELETE SERVER 'xxx.xxx.x.xx3:2882' ZONE='z3';Execute the following statement to query existing OBServer nodes. If the preceding OBServer nodes are not included in the returned list, the delete operation is successful.
obclient> SELECT * FROM oceanbase.DBA_OB_SERVERS;