You can add a zone to scale out a cluster.
Procedure
Log on to the
systenant of the cluster as therootuser.Run the following command to log on. You must replace the related information in the command based on the actual database environment.
obclient -h10.xx.xx.xx -P2883 -uroot@sys -p***** -AFor more information about how to connect to OceanBase Database, see Overview of the Connect to OceanBase Database chapter in Develop Applications in MySQL Mode and Overview of the Connect to OceanBase Database chapter in Develop Applications in Oracle Mode.
Execute the following statement to add a zone to a cluster.
obclient [(none)]> ALTER SYSTEM ADD ZONE zone_name [IDC [=] 'idc_name', REGION [=] 'region_name', ZONE_TYPE [=] 'ReadWrite'];zone_name: the name of the zone to be added. This statement adds only one zone at a time. To add multiple zones, execute this statement repeatedly.idc_name: the name of the IDC where the zone is located. Default value: Null.region_name: the name of the region where the zone is located. Default value: the value ofdefault_region.ZONE_TYPE: the type of the zone. At present, only a read/write zone is supported. Default value:ReadWrite. If you do not specify this parameter, the default value is used.
For example, to add a zone named zone4 to the cluster, execute the following statement:
obclient [(none)]> ALTER SYSTEM ADD ZONE zone4 IDC 'hz1', REGION 'hangzhou';After the statement is executed, you can query the
oceanbase.DBA_OB_ZONESview to verify whether the zone is added.obclient [(none)]> SELECT * FROM oceanbase.DBA_OB_ZONES; +-------+----------------------------+----------------------------+----------+-----+----------+-----------+ | ZONE | CREATE_TIME | MODIFY_TIME | STATUS | IDC | REGION | TYPE | +-------+----------------------------+----------------------------+----------+-----+----------+-----------+ | zone1 | 2022-12-20 17:50:17.168745 | 2022-12-20 17:50:40.801054 | ACTIVE | HZ0 | hangzhou | ReadWrite | | zone2 | 2022-12-20 17:50:17.168745 | 2022-12-20 17:50:40.809504 | ACTIVE | HZ0 | hangzhou | ReadWrite | | zone3 | 2022-12-20 17:50:17.169804 | 2022-12-20 17:50:40.815833 | ACTIVE | SH0 | shanghai | ReadWrite | | zone4 | 2023-01-06 14:57:18.775946 | 2023-01-06 14:57:18.776974 | INACTIVE | hz1 | hangzhou | ReadWrite | +-------+----------------------------+----------------------------+----------+-----+----------+-----------+ 4 rows in setIf the zone appears in the query result, it is successfully added. A newly added zone is in the INACTIVE state.
For more information about the
oceanbase.DBA_OB_ZONESview, see oceanbase.DBA_OB_ZONES.To use a newly added zone, you must start it so that it changes to the ACTIVE state.
obclient [(none)]> ALTER SYSTEM START ZONE zone_name;In the statement,
zone_namespecifies the name of the zone to be started.Here is an example:
obclient [(none)]> ALTER SYSTEM START ZONE zone4; Query OK, 0 rows affected obclient [(none)]> SELECT * FROM oceanbase.DBA_OB_ZONES; +-------+----------------------------+----------------------------+--------+-----+----------+-----------+ | ZONE | CREATE_TIME | MODIFY_TIME | STATUS | IDC | REGION | TYPE | +-------+----------------------------+----------------------------+--------+-----+----------+-----------+ | zone1 | 2022-12-20 17:50:17.168745 | 2022-12-20 17:50:40.801054 | ACTIVE | HZ0 | hangzhou | ReadWrite | | zone2 | 2022-12-20 17:50:17.168745 | 2022-12-20 17:50:40.809504 | ACTIVE | HZ0 | hangzhou | ReadWrite | | zone3 | 2022-12-20 17:50:17.169804 | 2023-01-30 17:34:11.228474 | ACTIVE | HZ1 | hangzhou | ReadWrite | | zone4 | 2023-01-06 15:30:30.887362 | 2023-01-31 13:47:56.107429 | ACTIVE | hz1 | hangzhou | ReadWrite | +-------+----------------------------+----------------------------+--------+-----+----------+-----------+ 4 rows in setAfter the zone is started, its status changes to
ACTIVE.
What to do next
After you add a zone, you can modify its
idc_nameorregion_name. For more information about how to modify a zone, see Modify a zone.To use a newly added zone, you must first add nodes to the zone. For more information about how to add a node, see Add a node.
A newly added zone is in the
INACTIVEstate. To enable nodes in the zone to provide services, you must start the zone. For more information about how to start zone, see Start a zone.
More information
For more zone-related O&M operations, see the following topics: