This topic describes how to scale in an OceanBase cluster by deleting OBServer nodes from zones.
You can delete OBServer nodes from a zone by executing SQL statements or using OceanBase Cloud Platform (OCP).
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 OCP, see View resource information 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 need to delete the same number of OBServer nodes from each zone.
Assume that you have a cluster that contains three zones, which are z1, z2, and z3, and each zone contains 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, MAX_MEMORY '36G', MIN_MEMORY '36G', MAX_IOPS 128, MIN_IOPS 128, MAX_DISK_SIZE '2T', MAX_SESSION_NUM 64;
obclient> CREATE RESOURCE POOL pool1 UNIT 'unit1', UNIT_NUM 2, 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 contains only one OBServer node.
Example:
Log on to the
systenant as therootuser.Reduce the resource configurations of the tenant by decreasing the value of the
UNIT_NUMparameter based on your business requirements.Notice
One resource unit can be located on only one OBServer node. If you have adjusted the resource unit specifications to the optimal settings during the tenant scale-in, you must reduce the number of resource units in this step.
The modified number of resource units must not be greater than the expected number of OBServer nodes available in each zone after the deletion of OBServer nodes.
In this case, the number of resource units is changed to 1. Sample statement:
obclient> ALTER RESOURCE POOL pool1 UNIT_NUM 1;You can also reduce the value of the
UNIT_NUMparameter by specifyingunit_id. For more information, see Scale in or out a tenant by modifying the UNIT_NUM parameter.After you run the command, you can query the internal table
oceanbase.__all_unitto check whether the number of resource units of the tenant is reduced. If thestatusof all units in the returned result isACTIVE, which means no unit is in theDELETINGstate, the operation is successful.Execute the following statements to delete an OBServer node from each zone.
In the statements,
xxx.xxx.x.xx1,xxx.xxx.x.xx2, andxxx.xxx.x.xx3indicate 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 server list, the delete operation is successful.
obclient> SELECT * FROM oceanbase.__all_server;
Delete OBServer nodes from zones in OCP
You can delete OBServer nodes from zones in OCP. Generally, you need to delete the same number of OBServer nodes from each zone.
Assume that you have a cluster that has three zones, which are z1, z2, and z3, and each zone has two OBServer nodes. Assume that you need to delete one OBServer node from each zone. After the scale-in, each of the three zones contains only one OBServer node.
Procedure:
Log on to the OCP console.
Modify the required resource pool of the tenant based on your business needs. To be specific, reduce the number of resource units in each zone.
Notice
One resource unit can be located on only one OBServer node. If you have adjusted the resource unit specifications to the optimal settings during the tenant scale-in, you must reduce the number of resource units in this step.
For more information about how to modify a resource pool in OCP, see Modify a resource pool.
Delete one OBServer node from each of the three zones.
For more information about how to delete OBServer nodes from zones in OCP, see Delete an OBServer node.