Add a zone

2023-11-24 02:58:23  Updated

You can add a zone to scale out a cluster.

Procedure

  1. Log on to the sys tenant of an OceanBase cluster as the root user.

    Note that you must specify the corresponding fields in the following sample code based on your actual database configurations.

    obclient -h10.xx.xx.xx -P2883 -uroot@sys#obdemo -p***** -A
    

    For more information about how to connect to a database, see Connection methods (MySQL mode) or Connection methods (Oracle mode).

  2. 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_name specifies 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 specifies the name of the IDC where the zone is located. The default value is Null.

    • region_name specifies the name of the region where the zone is located. The default value is the value of default_region.

    • ZONE_TYPE specifies the type of the zone. At present, only a read-write zone is supported. The default value is ReadWrite. 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';
    
  3. After the statement is executed, you can query the oceanbase.DBA_OB_ZONES view 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 set
    

    If 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_ZONES view, see oceanbase.DBA_OB_ZONES.

  4. To use a newly added zone, you must start it so that it changes to the ACTIVE state.

    Here is an example:

    obclient [(none)]> ALTER SYSTEM START ZONE zone_name;
    

    In the statement, zone_name specifies 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 set
    

    After the zone is started, its status changes to ACTIVE.

What to do next

  • After you add a zone, you can modify its idc_name or region_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 INACTIVE state. 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:

Contact Us