To support scenarios such as mixed TP and AP workloads, OceanBase Database supports columnstore replicas (COLUMNSTORE, abbreviated as C replicas). C replicas can be deployed on independent zones; user tables (including replicated tables, excluding index tables, internal tables, and system tables) are stored in columnstore format within this replica.
This topic describes the steps to deploy a columnstore replica (C replica) in the tenant's Locality, and how to use a C replica.
Note
Accessing a C replica depends on the configuration of standalone ODP (ODP V4.3.2+) and weak-consistency read + columnstore routing. For version baselines and architecture selection, see the description at the beginning of Typical AP Architecture Deployment Guide.
Limitations and considerations
Limitations
- C replicas and F or R replicas cannot be converted into each other.
- Physical restore does not support restoring C replicas; if a tenant's locality includes C replicas, the restore will fail.
Deployment recommendations
- Deploying multiple C replicas is supported starting from V4.3.5 BP1. It is recommended to have at most 3.
- A Zone that hosts C replicas must only host C replicas; the independent ODP accessing the C replicas must be ODP V4.3.2 or later.
- When no C replicas are deployed on the primary database, it is not recommended to deploy C replicas on the standby database.
O&M considerations
- Performing DDL operations in a cluster with C replicas typically increases system resource consumption. The main reason is that while processing row data, the system also needs to handle column data, and commit logs (clogs) must be written synchronously to the corresponding replicas, thus putting greater pressure on resources such as CPU, memory, disk, and I/O.
- C replica major compaction is usually slower than F/R compaction. A new round of tenant-level compaction cannot be initiated until the previous round is complete. Before manually initiating a major compaction, it is recommended to check CDB_OB_ZONE_MAJOR_COMPACTION and DBA_OB_ZONE_MAJOR_COMPACTION, for details see View compaction information.
Deploy columnstore replicas
Specify C replicas in the tenant's Locality, which involves two common scenarios:
- Scenario A: Create a tenant with C replicas from the start.
- Scenario B: Add C replicas to an existing tenant (new Zone + adjust Locality).
The CPU, memory, disk, and other values in the following SQL examples are for reference only. Adjust them according to your actual workload and resource planning.
Scenario A: Create a new tenant containing C replicas
Assume there is already a deployed cluster with a deployment mode of 2F1A (two replicas + one arbitration service). The three Zones in the cluster are named zone1, zone2, and zone3, with the arbitration service deployed on zone3. To create a tenant containing C replicas on this cluster, follow these steps:
Note
C replicas cannot replace arbitration (A). In a three-zone scenario, you can directly configure F@zone1,F@zone2,C@zone3; there is no need to add a fourth Zone.
Find a machine that can communicate with the current cluster network, and deploy an ODP dedicated to accessing C replicas on that machine (see the preceding section for deployment and version requirements).
An independent ODP can be deployed on any host that communicates with the cluster network; it is not necessary to use a dedicated physical server. To prevent resource contention, it is recommended to deploy the ODP on a single machine. When deploying the ODP, its version must be ODP V4.3.2 or later. For detailed ODP deployment instructions, see Deploy ODP.
Create a resource unit
unit1for the tenant.CREATE RESOURCE UNIT unit1, MAX_CPU=5, MIN_CPU=5, MEMORY_SIZE= '32G', MAX_IOPS=10000, MIN_IOPS=5000, LOG_DISK_SIZE=5301023539200;Create a resource pool
pool1for the tenant, specifying the resource unit asunit1.CREATE RESOURCE POOL pool1 UNIT='unit1', UNIT_NUM = 1, ZONE_LIST = ('zone1','zone2','zone3');Create a tenant named
tenant_c, specifying its Locality asF@zone1,F@zone2,C@zone3.CREATE TENANT tenant_c LOCALITY = 'F@zone1,F@zone2,C@zone3', PRIMARY_ZONE='zone1;zone2,zone3', RESOURCE_POOL_LIST=('pool1') SET ob_tcp_invited_nodes = '%';In this example, the created tenant is a MySQL-compatible mode tenant by default. To create an Oracle-compatible mode tenant, you need to explicitly specify
ob_compatibility_mode='oracle'using the system variable ob_compatibility_mode.
Scenario B: Add a C replica for an existing tenant
Assume there is a tenant named tenant_c in the current cluster. Its locality is F@zone1,F@zone2,F@zone3, the tenant's resource pool is pool1, and its ZONE_LIST range is 'zone1','zone2','zone3'. Now you need to add a C replica for the tenant by adding zone4, then modifying the tenant's locality to F@zone1,F@zone2,F@zone3,C@zone4. The steps are as follows:
Note
Adding a fourth zone applies only to scenarios where you want to place the C replica in a separate zone; it is not a prerequisite for deploying the C replica. If the three-zone topology already meets isolation requirements, you can directly configure the C replica on the existing zones (for example, F@zone1,F@zone2,C@zone3).
Add a new zone zone4 to the cluster. For detailed operations on adding a zone, see Add a zone.
Add nodes to zone4. For detailed operations on adding nodes, see Add a node.
Create the resource unit
unit2.CREATE RESOURCE UNIT unit2, MAX_CPU=5, MIN_CPU=5, MEMORY_SIZE= '32G', MAX_IOPS=10000, MIN_IOPS=5000, LOG_DISK_SIZE=5301023539200;Create the resource pool
pool2and assign it the resource unitunit2.CREATE RESOURCE POOL pool2 UNIT = 'unit2', UNIT_NUM = 1, ZONE_LIST = ('zone4');Add the resource pool
pool2for the tenant.ALTER TENANT tenant_c RESOURCE_POOL_LIST = ('pool1','pool2');Notice
RESOURCE_POOL_LISThas a complete table replacement semantics: you must list both the existing and the new resource pool. If you write only('pool2'), the original resource pool will be unbound.Modify the tenant's locality to
F@zone1,F@zone2,F@zone3,C@zone4.ALTER TENANT tenant_c LOCALITY = 'F@zone1,F@zone2,F@zone3,C@zone4';
Use columnstore replicas
Access the C replica through a dedicated ODP
When accessing the C replica, you need to deploy a separate set of ODP (ODP V4.3.2+). The business sends requests to the C replica through this ODP: configure weak read, routing, and init_sql on it (commonly ob_route_policy = COLUMN_STORE_ONLY, etc.). A complete example is shown below.
In multi-IDC scenarios, if you need both IDC-affinity routing (LDC) and columnstore routing, consider them two independent configuration dimensions. For related FAQs, see AP FAQ.
Deploy ODP
Deploy dedicated for accessing the C replica ODP on a machine that can communicate with the cluster, with a version not earlier than ODP V4.3.2. For steps, see Deploy ODP.
Configure routing forwarding policies and weak-consistency reads
Log in to the ODP as root@proxysys, for example:
obclient -uroot@proxysys -h10.10.10.1 -P2883 -p
Common parameters
The following table lists common ODP parameters related to weak-consistency reads from columnar storage.
Parameter |
Description |
|---|---|
obproxy_read_only |
Whether to forward only read-only requests and other proxy read-only mode-related behaviors. When used with weak consistency reads or routing, please configure according to the actual ODP version instructions. |
obproxy_read_consistency |
Read consistency level. In the example, it is= 1Often represents weak-consistency read (subject to the current ODP documentation), facilitating routing to follower replicas or C replicas. |
proxy_primary_zone_name |
Routes requests preferentially to a specified Zone (commonly used when the Zone where the leader replica resides is known, and you want weak-consistency read traffic to converge by Zone). |
init_sql |
SQL statements that are automatically executed after a connection is established. Commonly used forset @@ob_route_policy = COLUMN_STORE_ONLYEnables the optimizer to generate columnar storage paths. |
route_target_replica_type |
Route by replica type, for example,ColumnStoreindicates that the columnstore replica is selected (without relying on the write-only zone name). |
proxy_route_policy |
Routing strategy enumeration; for example,TARGET_REPLICA_TYPE_FOLLOWER_ONLYIndicates that weak read routing is performed only from follower replicas, and the connection is disconnected when a follower replica is unavailable. (For details, refer to the ODP documentation.) |
Scenario combinations
combination |
Application scenarios |
proxy_primary_zone_name |
route_target_replica_type |
init_sql |
proxy_route_policy(Optional) |
|---|---|---|---|---|---|
| Combination 1 | The zone where the leader replica is located has been identified. Weak-consistency reads are expected to converge by zone. | Set it to the zone where the leader replica is located, for example,'zone4' |
Not dependent (leave default) | set @@ob_route_policy = COLUMN_STORE_ONLY |
Optional, see "Option 2" below |
| Combination 2 | Prefer to select columnar storage by replica type rather than being bound to a fixed zone name | Optional. Set as needed. | 'ColumnStore' |
set @@ob_route_policy = COLUMN_STORE_ONLY |
To enable features such as "Connect only from replicas. Disconnect if unavailable", you can set it toTARGET_REPLICA_TYPE_FOLLOWER_ONLY(see below) |
Combination 1: Execution example (weak-consistency read + Route to replica C by zone)
-- Configure read-only and weak-consistency read-related items.
obclient> ALTER PROXYCONFIG SET obproxy_read_only = 0;
obclient> ALTER PROXYCONFIG SET obproxy_read_consistency = 1;
-- Configure to route all requests to the zone where replica C resides and generate a query plan for replica C during a weak-consistency read. For example, assume the zone where replica C resides is zone4.
obclient> ALTER PROXYCONFIG SET proxy_primary_zone_name='zone4';
obclient> ALTER PROXYCONFIG SET init_sql='set @@ob_route_policy = COLUMN_STORE_ONLY';
Combination 2: Execution example (weak-consistency read + Route to ColumnStore replica)
-- Configure read-only and weak-consistency read-related items.
obclient> ALTER PROXYCONFIG SET obproxy_read_only = 0;
obclient> ALTER PROXYCONFIG SET obproxy_read_consistency = 1;
-- Configure to route all requests to replica C and generate a query plan for replica C during a weak-consistency read:
obclient> ALTER PROXYCONFIG SET route_target_replica_type = 'ColumnStore';
-- Configure to select only from replicas during a weak-consistency read and disconnect from the client if no replicas are available:
obclient> ALTER PROXYCONFIG SET init_sql='set @@ob_route_policy = COLUMN_STORE_ONLY';
After successful modification, verify the configuration with the following statement:
obclient> SHOW PROXYCONFIG ALL LIKE 'obproxy_read_only';
obclient> SHOW PROXYCONFIG ALL LIKE 'obproxy_read_consistency';
obclient> SHOW PROXYCONFIG ALL LIKE 'proxy_primary_zone_name';
obclient> SHOW PROXYCONFIG ALL LIKE 'init_sql';
obclient> SHOW PROXYCONFIG ALL LIKE 'route_target_replica_type';
obclient> SHOW PROXYCONFIG ALL LIKE 'proxy_route_policy';
After successful configuration, OLAP services access the database through this standalone ODP, directing queries to replica C.
