OceanBase 4.x Primary-Standby Architecture Explained: Second-Level Disaster Recovery and Dual-Active Deployment

OceanBase 4.x lowers primary-standby granularity to the tenant level, using dual log synchronization modes to achieve second-level disaster recovery and low-cost dual-active.
The core change in OceanBase 4.x primary-standby architecture is lowering the primary-standby relationship from cluster level to tenant level, with clusters fully independent and tenant specifications and Locality no longer required to align, greatly improving flexibility and resource utilization. The architecture consists of three core components: log transport, log storage, and log replay. Standby tenants actively pull logs and support both direct network connection and log archive synchronization, which must be consistent under the same primary-standby relationship. For switching, Switchover is lossless with RPO=0, while Failover is lossy with RPO>0, both completing within seconds. In typical scenarios, same-city dual-datacenter disaster recovery and dual-active deployment benefit from tenant-level granularity; dual-active requires only two clusters, significantly reducing resource and management costs compared with 3.x. During operations, note limitations such as standby tenants being read-only, major compaction requiring synchronization from the primary tenant, and upgrading standby before primary.
OceanBase 4.x Primary-Standby Architecture Explained: Second-Level Disaster Recovery and Dual-Active Deployment
In the high-availability architecture of distributed databases, Primary-Standby is a classic and widely adopted disaster recovery solution. OceanBase introduced primary-standby capabilities back in the 3.x era, and in version 4.x this architecture has undergone significant upgrades, becoming more flexible, lightweight, and easier to operate and maintain. Database expert Yan Jun (alias: Meijiyuan) from Alibaba detailed the core design, component composition, and deployment practices of OceanBase 4.x primary-standby architecture in a Bilibili sharing session. This article is based on that sharing and provides an in-depth analysis combined with architectural logic.
I. From Cluster-Level to Tenant-Level: The Core Change in Architecture Evolution
The most notable change in OceanBase 4.x primary-standby is the granularity of the primary-standby relationship being lowered from cluster-level to tenant-level. In version 4.2, standby databases adopt an independent primary-standby architecture, with each cluster completely independent of one another, allowing users to manage cluster resources more flexibly. Tenant names no longer need to match between primary and standby, and configurations such as tenant specifications and Locality no longer need to correspond one-to-one. However, from an operations and stability perspective, experts still strongly recommend maintaining parity at the resource level.

Compared with 3.x, 4.x primary and standby tenants only provide asynchronous synchronization mode, and no longer support maximum protection and maximum availability modes. According to Yan Jun, not many customers actually adopt maximum protection mode in production; if similar capabilities are still needed, they can be indirectly achieved through 4.x's arbitration replica (arbitration service) by setting the timeout to 0. This trade-off simplifies the architecture and also reduces the complexity of the synchronization link.
Another key change is that the log transport service provides two modes: physical standby based on log archiving and physical standby based on network. At the same time, after decoupling, the replicas of primary and standby tenants run independently, and direct connections are no longer mandatory to maintain membership relationships.
II. Three Core Components: Log Transport, Storage, and Replay
The OceanBase 4.x primary-standby architecture consists of three core components that together complete the flow and application of logs from the primary tenant to the standby tenant.
Log Transport Service
The log transport service is responsible for synchronizing Redo logs between the primary tenant and the standby tenant. It should be emphasized that the primary tenant does not actively push logs to the standby tenant; instead, the standby tenant actively pulls logs from the primary tenant (Pull mode). This service automatically addresses the log position and handles scenarios where logs fall behind. It can obtain logs either through the primary tenant's archive log service or through a direct network connection to the cluster where the primary tenant resides.
Log Storage Service
The log storage service provides highly available and highly reliable log storage and read/write capabilities for physical standby databases, and can be either single-replica or Paxos multi-replica. The log storage services of primary and standby tenants have two distinctly different working modes: the primary tenant uses Append mode, receiving writes from upper-layer transactions and DDL; the standby tenant uses Roll Write mode, allowing logs to be obtained only through the log transport service from other tenants or log archives, and disallowing modification by other services, thereby further protecting data security.

Paxos multi-replica is the underlying consensus protocol through which OceanBase achieves high availability. Within a log stream, multiple replicas (usually three or five replicas) are distributed across different Zones or servers, and log writes are voted on and confirmed through the Paxos protocol. Only after a majority of replicas confirm the write is the log considered successfully persisted. This mechanism ensures that even if a minority of replicas fail, log data will not be lost, and a new primary replica can be automatically elected to continue providing service. In the primary-standby architecture, the primary tenant's log storage typically uses Paxos multi-replica to ensure its own high availability, while the standby tenant's log storage can choose single-replica to save resources, because the standby tenant's log source depends on the primary tenant or archives, and its own high-availability requirements are relatively lower.
Log Replay Service
Logs written by the standby tenant to the log storage service are applied to memory in real time through the log replay service, ensuring data consistency between the primary tenant and the standby tenant.
Log replay refers to the process by which the standby tenant applies received Redo logs to memory in order. Its essence is replaying transaction operations that have already been executed on the primary tenant. The replay service needs to ensure the continuity and consistency of log application, and usually adopts parallel replay technology to improve efficiency. In OceanBase, log replay remains consistent with the primary tenant's commit order, ensuring that the standby tenant's data snapshot is completely consistent with the primary tenant at a certain point in time. Replay latency directly affects RPO, so the standby tenant's log replay performance is one of the key indicators for measuring standby database health.
III. Two Log Synchronization Methods: Direct Network Connection and Archive Synchronization
Version 4.x provides two log synchronization methods for physical standby databases, adapted to different deployment environments.
Network-based physical standby: The standby tenant directly connects to the primary tenant or other standby tenants over the network to read logs, similar to MySQL's Replication mode. This method requires network connectivity between primary and standby tenants. The standby tenant obtains the primary tenant's logs by sending network RPC requests, and the logs can be either the primary tenant's online logs or archive logs (the primary tenant must enable archiving). Internally, automatic switching between the two log sources is supported, transparent to the business, with latency usually at the second level.
Log archive-based physical standby: The standby tenant interacts only with the log archive and does not establish network connections with the upstream primary tenant or other standby tenants, similar to Oracle's FastSync mode. In this deployment mode, primary and standby tenants do not need network connectivity, making it very suitable for multi-cloud architectures—connecting networks through dedicated lines is costly, while the archive-based approach can conveniently implement cross-cloud standby databases. However, its performance may be affected by the archive medium, and latency may reach the minute level.
Yan Jun specifically pointed out that under the same primary-standby relationship, only the same synchronization method is supported, that is, either all based on network or all based on archiving. Storage media currently supported for archiving include NFS and Alibaba Cloud OSS.
IV. Disaster Recovery Switching: Switchover and Failover
OceanBase primary-standby provides two switching capabilities, both of which can be completed within seconds.
Switchover (lossless switchover): Used for planned switching, where the primary tenant and standby tenant exchange roles without data loss, RPO equals 0, and switching time is at the second level. The operation can only be initiated from the primary tenant, requires log latency not greater than 5 seconds, and the standby tenant must have log archiving enabled; otherwise, switching is not allowed.
Failover (lossy switchover): Used for forced switching after a primary cluster failure, forcibly converting the standby tenant into the primary tenant. In this case, RPO is greater than 0, and switching time is also at the second level. The operation can only be initiated from the standby tenant, and the premise is that the corresponding primary tenant cannot operate normally.
Both types of switching require all replicas of the standby tenant's log stream to be online, which is a basic requirement for ensuring standby database health.
V. Typical Deployment Scenarios: Same-City Dual-Datacenter and Dual-Active
The most typical deployment scenario for primary-standby is same-city or cross-region dual-datacenter. Users can use the physical standby feature to meet various requirements for cross-region disaster recovery, and use the OCP management tool to switch the primary-standby roles of all tenants. Each datacenter deploys one cluster; when the primary datacenter is unavailable, the standby datacenter takes over the business, with RPO greater than 0.

In dual-active scenarios, the business has read-write and cross-region capacity requirements in two different regions. Usually, unitization is combined so that part of the traffic is in city A and part in city B, and in abnormal situations the traffic of city A can be switched entirely to city B. Because 4.x lowers primary-standby granularity to the tenant level, the dual-active architecture only needs one cluster deployed in each of the primary and standby cities to meet requirements; in the 3.x cluster-level primary-standby era, four clusters might need to be deployed, significantly increasing resource costs and management complexity.
VI. Setup and Operations Best Practices
There are three ways to create a standby tenant, corresponding to different log synchronization combinations:
- Create a standby tenant based on direct network connection, with subsequent network-based synchronization, suitable for scenarios where the primary tenant has just been created and Redo logs are complete;
- Create a standby tenant based on backup and restore, with subsequent network-based synchronization, suitable for scenarios where the primary tenant has log archives and data backups and the primary and standby networks are interconnected;
- Create a standby tenant based on backup and restore, with subsequent archive log-based synchronization, suitable for scenarios where the primary and standby networks do not need to be directly connected.

In daily operations, several limitations should be noted: standby tenants support read operations but not write operations; on 4.x, read-only behavior can be performed directly without setting read-only hints; dump operations of primary and standby tenants are relatively independent, but major compaction must be synchronized from the primary tenant, and standby tenants do not support independent major compaction; configuration items are independent between primary and standby, so when modifying primary tenant configurations, confirm whether the same settings need to be synchronized on the standby tenant, while system variables (such as timeout) can be physically synchronized.
Regarding upgrades, it is recommended to upgrade the standby tenant's OB cluster first, and then upgrade the primary tenant's cluster. If the primary is upgraded before the standby, the standby database synchronization may temporarily stall due to schema adjustments.
Conclusion
Through tenant-level granularity, dual log synchronization modes, sequential synchronization optimization, and independent operations capabilities, OceanBase 4.x primary-standby greatly reduces resource overhead and management complexity while maintaining second-level disaster recovery switching. For enterprises requiring same-city dual-datacenter disaster recovery or cross-region dual-active, this architecture provides a pragmatic choice that balances cost and reliability.
Background Supplement
RPO (Recovery Point Objective) refers to the amount of data loss a system can tolerate after a disaster occurs, usually measured in time. RPO=0 means no committed data is lost during switching; RPO>0 means data from the most recent period that has not yet been synchronized may be lost. In OceanBase primary-standby, Switchover is a planned lossless switchover, so RPO=0; while Failover is a forced switchover after a failure, and because the primary tenant may still have logs not yet transmitted to the standby tenant, RPO is greater than 0. RPO is a core metric in disaster recovery solution design and directly determines the business's tolerance for data loss.
Unitization is an architectural pattern that splits business traffic by user dimension into different geographical units (Units). Each unit usually contains complete application services and database services and can independently handle read/write requests for a subset of users. In dual-active scenarios, unitization is used in combination with primary-standby: city A and city B each deploy one unit, carrying traffic for different users respectively, while data synchronization is achieved through primary and standby tenants. When a failure occurs in one city, the traffic of that city can be switched entirely to the other city, and the unit in the other city takes over all business. This architecture not only achieves cross-region disaster recovery but also improves resource utilization through traffic distribution.
Related articles

n8n's Open-Source AI Agent Nod: Self-Hostable, Model-Optional
n8n launches Nod, an open-source AI agent supporting self-hosting, any model choice (including local models), proactive background execution, broad app connections, and excellent secure defaults with a built-in vault for passwords and credit card info.

Clay Builds a Sales Growth Engine with Codex and ChatGPT
Clay builds a self-learning revenue engine with GPT-6 Sol and Astra, using Codex to orchestrate GTM plays and enrich leads so reps focus on high-value conversations.

Deep Learning for Graduate Students: A Six-Step Method to Get Past Training Pipeline Roadblocks
Stuck on getting your deep learning training pipeline to run? This six-step method covers neural network basics, PyTorch, CNN, Transformer, paper reproduction, and experiment design.