This topic describes how to scale in a cluster by deleting zones from the cluster.
Considerations
This method applies only to a cluster with more than three zones. A cluster of less than three zones cannot form a high-availability architecture to support IDC-level disaster recovery.
Notice
After a zone is deleted, all tenants using the zone are affected. Therefore, you must properly plan ahead to avoid the impact. This topic provides an example to describe how to delete a zone when only one tenant is affected.
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.
You can delete zones from a cluster by executing SQL statements or using OCP.
Delete zones from a cluster by using SQL statements
You can use SQL statements to delete zones from a cluster. For example, you can use this method to decrease the number of replicas from 5 to 3 for a tenant. You need to delete both zones and OBServer nodes from the relevant cluster.
For example, the current cluster contains five zones, which are z1, z2, z3, z4, and z5. The five zones belong to the same region, and each zone contains one OBServer node. The cluster has a regular tenant tenant1. Information about the tenant: CREATE TENANT IF NOT EXISTS tenant1 CHARSET='utf8mb4', ZONE_LIST=('z1','z2','z3','z4','z5'), PRIMARY_ZONE='z1,z2,z4', RESOURCE_POOL_LIST=('pool1'). Information about replica distribution: locality='F@z1,F@z2,F@z3,F@z4,F@z5', resource_pool_list=('pool1'). Information about resource distribution in the resource pool: CREATE RESOURCE POOL pool1 UNIT 'uc1', UNIT_NUM 1, ZONE_LIST ('z1','z2', 'z3','z4', 'z5').
Assume that you need to decrease the number of replicas from 5 to 3 for tenant1 based on your business needs. In other words, you need to change the locality information about the tenant to locality='F@z1,F@z2,F@z3,'. The following example describes how to delete z4 and z5, which are used only by the tenant tenant1.
Log on to the
systenant as therootuser.Optional. If the tenant uses
z4orz5as the primary zone, you must change the primary zone to another zone.obclient> ALTER TENANT tenant_name PRIMARY_ZONE='z1,z2,z3';Modify the locality of
tenant1to delete replicas:Based on the locality modification rule, you can delete only one zone at a time. For more information about the locality modification rule, see Overview.
obclient>ALTER TENANT tenant1 LOCALITY='F@z1,F@z2,F@z3,F@z4'; obclient>ALTER TENANT tenant1 LOCALITY='F@z1,F@z2,F@z3';Execute the following statements to stop
z4andz5.obclient> ALTER SYSTEM STOP ZONE z4; obclient> ALTER SYSTEM STOP ZONE z5;Remove
z4andz5from theZONE_LISTof the resource poolpool1:obclient> ALTER RESOURCE POOL pool1 ZONE_LIST=('z1','z2','z3');Execute the following statements to delete OBServer nodes from
z4andz5.Notice
In this example, only
tenant1tenant uses resources inz4andz5. If other tenants also usez4orz5, you need to perform steps 2 to 5 on those tenants.obclient> ALTER SYSTEM DELETE SERVER 'xxx.xxx.x.xx4:2882'; obclient> ALTER SYSTEM DELETE SERVER 'xxx.xxx.x.xx5:2882';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;After you confirm that the OBServer nodes are deleted, execute the following statements to delete the zones from the cluster:
obclient> ALTER SYSTEM DELETE ZONE z4; obclient> ALTER SYSTEM DELETE ZONE z5;Execute the following statement to query existing zones. If the preceding zones are not included in the returned zone list, the delete operation is successful.
obclient> SELECT * FROM oceanbase.__all_zone;The scale-in process is completed.
Delete zones from a cluster in OCP
You can delete zones from a cluster in OCP. For example, you can use this method to decrease the number of replicas from 5 to 3 for a tenant. You need to delete both zones and OBServer nodes from the relevant cluster.
For example, the current cluster contains five zones and the tenant1 tenant. The five zones are z1, z2, z3, z4, and z5, and each contains one OBServer node. The primary zones of the tenant1 tenant are z1, z2, and z4. Assume that you need to decrease the number of replicas from 5 to 3, and delete the two corresponding zones and the OBServer nodes in the zones from the cluster.
Procedure:
Log on to the OCP console.
Modify the priority of z4 to change the primary zones of the tenant to
z1,z2, andz3.For more information about how to modify the priority of a zone in OCP, see Modify the priority of a zone.
Delete the two replicas on
z4andz5in sequence.For more information about how to delete a replica in OCP, see Delete a replica.
Stop the two zones to be deleted.
For more information about how to stop a zone in OCP, see Start or stop a zone.
Delete the OBServer nodes from
z4andz5.For more information about how to delete OBServer nodes in OCP, see Delete an OBServer node.
Delete
z4andz5from the cluster.For more information about how to delete a zone in OCP, see Add or delete a zone.
The scale-in process is completed.