OceanBase Database provides three protection modes: MAXIMUM PERFORMANCE, MAXIMUM PROTECTION, and MAXIMUM AVAILABILITY. This topic describes how to switch between any two protection modes.
Background
You need to choose an appropriate protection mode based on your requirements for performance, data protection, and cluster availability. For more information, see Overview
Procedure
In the primary cluster, execute the following statement to query its protection mode:
obclient> SELECT CLUSTER_ROLE, PROTECTION_MODE FROM oceanbase.V$OB_CLUSTER; +--------------+--------------------+ | CLUSTER_ROLE | PROTECTION_MODE | +--------------+--------------------+ | PRIMARY | MAXIMUM PERFORMANCE| +--------------+--------------------+ 1 row in setProperly set the log transfer parameter for different standby clusters based on their protection modes.
obclient> ALTER SYSTEM MODIFY CLUSTER 'obcluster' CLUSTER_ID 3 SET REDO_TRANSPORT_OPTIONS = 'SYNC NET_TIMEOUT=30000000';For more information, see Log transfer service.
The requirements for the log transfer parameter vary with the protection mode.
MAXIMUM PERFORMANCE mode: none.
MAXIMUM PROTECTION mode: You can set only one standby cluster to be in
SYNCmode.MAXIMUM AVAILABILITY mode: You can set only one standby cluster to be in
SYNCmode. You can set theNET_TIMEOUTparameter for the standby cluster as required.
In the primary cluster, execute the following statement to query the log transfer parameter of all standby clusters.
obclient> SELECT CLUSTER_ID, REDO_TRANSPORT_OPTIONS FROM oceanbase.V$OB_STANDBY_STATUS; +------------+-----------------------------+ | CLUSTER_ID | REDO_TRANSPORT_OPTIONS | +------------+-----------------------------+ | 2 | SYNC NET_TIMEOUT = 30000000 | +------------+-----------------------------+ 1 row in setCheck the cluster status to ensure successful switching.
You can skip this step when you switch from other modes to the MAXIMUM PERFORMANCE or MAXIMUM AVAILABILITY mode. However, when you switch from other modes to the MAXIMUM PROTECTION mode, make sure that the following requirements are met:
The standby cluster in
SYNCmode is synchronized with the primary cluster.All OBServer nodes in the primary cluster are active.
If the requirements are not met, the switching fails.
To switch from other modes to the MAXIMUM PROTECTION mode, perform the following steps to check the cluster status:
Log on to the primary cluster and query the
SYNCHRONIZATION_STATUSfield in theV$OB_STANDBY_STATUSview to check the synchronization status of the target standby cluster.obclient> SELECT CLUSTER_ID, SYNCHRONIZATION_STATUS FROM oceanbase.V$OB_STANDBY_STATUS; +------------+------------------------+ | CLUSTER_ID | SYNCHRONIZATION_STATUS | +------------+------------------------+ | 2 | OK | +------------+------------------------+ 1 row in setIf
SYNCHRONIZATION_STATUSisOK, the standby cluster is synchronized with the primary cluster. IfSYNCHRONIZATION_STATUSis displayed as another value, the standby cluster is not synchronized with the primary cluster, and you need to identify the cause. For more information, see v$ob_standby_status.Log on to the primary cluster and query the
__ALL_SERVERtable to check whether all OBServer nodes are active.obclient> SELECT COUNT(*) FROM oceanbase.__ALL_SERVER WHERE STATUS != 'ACTIVE'; +----------+ | COUNT(*) | +----------+ | 0 | +----------+ 1 row in set
In the primary cluster, execute the following statement to switch its protection mode:
obclient> ALTER SYSTEM SET STANDBY CLUSTER TO MAXIMIZE {AVAILABILITY | PERFORMANCE | PROTECTION};Query the protection mode and protection level of each cluster to verify the switching result.
For more information, see Protection modes and protection levels.
obclient> SELECT PROTECTION_MODE, PROTECTION_LEVEL FROM oceanbase.V$OB_CLUSTER; +--------------------+--------------------+ | PROTECTION_MODE | PROTECTION_LEVEL | +--------------------+--------------------+ | MAXIMUM PROTECTION | MAXIMUM PROTECTION | +--------------------+--------------------+ 1 row in set