Locality describes the ways how data replicas are distributed and organized.
Replicas refer to the data itself, while locality refers to the container that holds the data. This means that the distribution strategies and types of containers described by locality apply to the data they contain.
In OceanBase Database v4.0, you can only set locality configurations at the tenant level. In OceanBase Database v3.x, locality configuration was available for tenants, tables, databases, and table groups.
Syntax
Syntax of locality:
replicas{count}@location
The following table describes the parameters in the syntax.
| Parameter | Description |
|---|---|
| replicas | The type of the replica. The value of this parameter is the name of the replica type. Both full names and abbreviations are supported. You can view the supported replica type names in the name column of the table in About replicas. |
| location | The location of the replica. It contains a collection of values that are known to the system. The value of this parameter is the names of zones. You can query for the names of zones in a cluster or tenant from the oceanbase.DBA_OB_ZONES view. For more information about the oceanbase.DBA_OB_ZONES view, see oceanbase.DBA_OB_ZONES. |
| count | If this parameter is not specified, only one replica is available. The value {n} indicates n replicas. A partition has at most one full-featured replica in a zone. |
You can query for the locality of a tenant from the LOCALITY field in the oceanbase.DBA_OB_TENANTS view of the system tenant. Example:
obclient> SELECT * FROM oceanbase.DBA_OB_TENANTS limit 10;
+-----------+-------------------------------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+
| TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED |
+-----------+-------------------------------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+
| 1 | sys | SYS | 2022-12-20 17:50:17.056814 | 2022-12-20 17:51:16.162367 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL | MYSQL | NORMAL | NO | NO |
| 1001 | META$1002 | META | 2022-12-20 18:04:31.683655 | 2023-02-02 17:41:43.928347 | zone1;zone3 | FULL{1}@zone1, FULL{1}@zone3 | NULL | MYSQL | NORMAL | NO | NO |
| 1002 | mysql001 | USER | 2022-12-20 18:04:31.689731 | 2023-02-02 17:41:43.927293 | zone1;zone3 | FULL{1}@zone1, FULL{1}@zone3 | NULL | MYSQL | NORMAL | NO | NO |
| 1009 | META$1010 | META | 2022-12-26 18:28:38.055294 | 2022-12-26 18:29:01.184333 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL | MYSQL | NORMAL | NO | NO |
| 1010 | oracle001 | USER | 2022-12-26 18:28:38.056350 | 2023-01-16 11:03:05.726746 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL | ORACLE | NORMAL | NO | NO |
| 1053 | META$1054 | META | 2023-01-30 15:07:38.504077 | 2023-01-30 15:07:58.740958 | zone1;zone2,zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL | MYSQL | NORMAL | NO | NO |
| 1054 | __recycle_$_100017_1675062478777896 | USER | 2023-01-30 15:07:38.505138 | 2023-02-23 14:53:44.500219 | zone1;zone2,zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL | MYSQL | NORMAL | YES | NO |
+-----------+-------------------------------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+
7 rows in set
Examples
The following example shows the locality of different tenants in a cluster that has five zones. The five zones are z1 to z5.

Locality of the sys tenant:
F@z1,F@z2,F@z3,F@z4,F@z5.This locality indicates that the sys tenant has a full-featured replica in z1, z2, z3, z4, and z5 respectively.
Locality of tenant1:
F@z1,F@z2,F@z3.This locality indicates that tenant1 has a full-featured replica in z1, z2, and z3 respectively.
Locality of tenant2:
F@z3,F@z4,F@z5.This locality indicates that tenant2 has a full-featured replica in z3, z4, and z5 respectively.
Locality and high-availability architecture
The multi-replica architecture is one of the strengths that distinguish OceanBase Database from conventional databases. The multi-replica architecture lays a foundation for multi-level lossless disaster recovery capabilities of OceanBase Database, including standalone lossless disaster recovery, lossless disaster recovery for IDCs, and city-wide lossless disaster recovery. OceanBase Database allows you to flexibly adjust the cluster deployment architecture to adapt to the technical evolution of business scenarios.
The flexible deployment architecture of OceanBase Database relies on the locality settings. Locality describes the replica types and the distribution strategies for replicas across zones. The region attribute of a zone describes the region to which the zone belongs. You can query for the region to which a zone belongs from the REGION field in the oceanbase.DBA_OB_ZONES view. You can adjust the distribution of multiple replicas of a tenant across zones in different regions to flexibly adjust the deployment mode.
OceanBase Database supports three typical deployment modes: three IDCs in the same city, three IDCs across two regions, and five IDCs across three regions. The following table describes the locality settings in different deployment modes.
| Deployment mode | Locality | Zone distribution |
|---|---|---|
| Three IDCs in the same city | F@z1,F@z2,F,F@z3 |
Zones z1, z2, and z3 belong to IDC 1, IDC 2, and IDC 3 in Region R1, respectively. |
| Three IDCs across two regions | F@z1,F@z2,F@z3,F@z4,F@z5 |
Zones z1 and z2 belong to IDC 1 in Region R1. Zones z3 and z4 belong to IDC 2 in Region R1. Zone z5 belongs to Region R2. |
| Five IDCs across three regions | F@z1,F@z2,F@z3,F@z4,F@z5 |
Zones z1 and z2 belong to IDC 1 and IDC 2 in Region R1. Zones z3 and z4 belong to IDC 3 and IDC 4 in Region R2. Zone z5 belongs to Region R3. |