You can add a zone to scale out a cluster.
Procedure
Log on 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:
obclient [(none)]> ALTER SYSTEM ADD ZONE zone_name [IDC [=] 'idc_name', REGION [=] 'region_name', ZONE_TYPE [=] 'ReadWrite'];where
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 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
INACTIVEstate.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;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 a zone, see Start a zone.
References
For more zone-related O&M operations, see the following topics: