This topic shows you how to create a replica for a tenant by using SQL statements and OceanBase Cloud Platform (OCP).
Limitations
If a tenant already has replicas in all zones of the cluster, you cannot create more replicas.
Create a replica by using SQL statements
SQL syntax for creating a resource unit
CREATE RESOURCE UNIT unit_name
MAX_CPU [=] cpu_num,
MAX_MEMORY [=] mem_size,
MAX_IOPS [=] iops_num,
MAX_DISK_SIZE [=] disk_size,
MAX_SESSION_NUM [=] session_num,
[MIN_CPU [=] cpu_num,]
[MIN_MEMORY [=] mem_size,]
[MIN_IOPS [=] iops_num];
SQL syntax for creating a resource pool
CREATE RESOURCE POOL poolname
UNIT [=] unitname,
UNIT_NUM [=] unitnum,
ZONE_LIST [=] ('zone' [, 'zone' ...]);
SQL syntax for allocating a resource pool to a tenant
ALTER TENANT tenant_name
RESOURCE_POOL_LIST [=](poolname [, poolname...]);
SQL syntax for adding a replica to a tenant
ALTER TENANT tenant_name LOCALITY [=] 'locality_description';
Examples
Assume that the tenant1 tenant has only one replica and this replica is hosted in zone1. You need to create a replica in zone2 for the tenant. You can execute the following SQL statements to create a replica and add the replica to the tenant1 tenant by modifying its locality:
Create a resource unit.
obclient> CREATE RESOURCE UNIT unit1 MAX_CPU 4, MAX_MEMORY '5G', MAX_IOPS 128,MAX_DISK_SIZE '10G', MAX_SESSION_NUM 64, MIN_CPU=4, MIN_MEMORY= '5G', MIN_IOPS=128;Create a resource pool for zone 2.
obclient> CREATE RESOURCE POOL pool2 UNIT='unit1', UNIT_NUM=1, ZONE_LIST=('zone2');Allocate the resource pool of zone2 to tenant1.
obclient> ALTER TENANT tenant1 resource_pool_list=('pool1','pool2');Add a full-featured replica of zone2 to tenant1.
obclient> ALTER TENANT tenant1 locality='F@zone1,F@zone2';
Create a tenant in OCP
Log on to the OCP console.
In the left-side navigation pane, click Tenants.
In the Tenants list, find the target tenant and click its name to go to the Overview page of the tenant.
Click Create Replica in the upper-right corner of the page.

In the dialog box that appears, specify Target Zone, Replica Type, and Resource Pool.

Parameter Description Target Zone The zone where the new replica exists. You can select a zone of the current cluster. Replica Type Valid values: Full-featured Replica, Read-only Replica, and Log Replica. - Full-featured Replica: A standard replica that provides complete data and features, including transaction logs, a MemTable, and an SSTable. A full-featured replica can switch to the leader role efficiently to provide services.
- Read-only Replica: A replica that contains full logs, a MemTable, and an SSTable. It does not participate in log voting as a member of the Paxos group. Instead, it works as an observer that synchronizes logs from the Paxos group members and then locally replays the logs.
- Log Replica: A replica that contains only logs. It does not have a MemTable or an SSTable. It provides log services for external applications and participates in log voting. It can facilitate the recovery of other replicas, but it cannot become the leader to provide database services.
Resource Pool Specify the unit specifications and the number of units. Click OK.