You can add a zone to scale out a cluster.
Procedure
Log in to the
systenant of the cluster as therootuser.Note that you must specify the corresponding options in the following sample code based on your actual database configurations.
obclient -h10.xx.xx.xx -P2883 -uroot@sys#obdemo -p***** -AFor more information about how to connect to a database, see Connection methods (MySQL mode) or Connection methods (Oracle mode).
Execute the following statement to add a zone to a cluster:
Here is a sample statement:
obclient [(none)]> ALTER SYSTEM ADD ZONE zone_name [IDC [=] 'idc_name', REGION [=] 'region_name', ZONE_TYPE [=] 'ReadWrite'];The parameters are described as follows:
zone_namespecifies 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_namespecifies the name of the IDC where the zone is located. The default value is Null.region_namespecifies the name of the region where the zone is located. The default value is the value ofdefault_region.ZONE_TYPEspecifies the type of the zone. At present, only a read-write zone is supported. The default value isReadWrite. If you do not specify this parameter, the default value is used.
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 operation succeeds, query the
oceanbase.DBA_OB_ZONESview to verify the result.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 query result contains the newly added zone, the zone is added successfully. The status of the newly added zone is
INACTIVE.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
ACTIVEstate.Here is a sample statement:
obclient [(none)]> ALTER SYSTEM START ZONE zone_name;Here,
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 setAs shown in the preceding example, after the zone is started successfully, the status of the newly added zone 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.
References
For more zone-related O&M operations, see the following topics:
