This topic describes the preparations before you switch the primary and standby roles, including the steps of obtaining cluster information and selecting a standby cluster to switch it to the primary role.
Obtain cluster information
Query the V$OB_CLUSTER view to obtain the role, status, protection mode, and protection level of each cluster.
Example:
Run the following command to obtain the role and status of the current cluster:
obclient> SELECT CLUSTER_ID, CLUSTER_NAME, CLUSTER_ROLE, CLUSTER_STATUS FROM V$OB_CLUSTER; +------------+--------------+--------------+----------------+ | CLUSTER_ID | CLUSTER_NAME | CLUSTER_ROLE | CLUSTER_STATUS | +------------+--------------+--------------+----------------+ | 1 | obcluster | PRIMARY | VALID | +------------+--------------+--------------+----------------+ 1 row in setIn the example:
CLUSTER_IDindicates the ID of the current cluster. The primary and standby clusters have different cluster IDs.CLUSTER_NAMEindicates the name of the current cluster. The primary and standby clusters have the same cluster name.CLUSTER_ROLEindicates the role of the current cluster.PRIMARYindicates a primary cluster, andPHYSICAL STANDBYindicates a standby cluster.CLUSTER_STATUSindicates the status of the current cluster.VALIDindicates that the cluster is normal.DISABLEDindicates that synchronization is disabled. Only the primary and standby clusters in theVALIDstate support role switchover.
After you identify the primary cluster, you can query the
V$OB_STANDBY_STATUSview of the primary cluster to obtain the list of all standby clusters and their status.In this example, two standby clusters whose IDs are respectively
2and3are in theVALIDstate.obclient> SELECT CLUSTER_ID, CLUSTER_NAME, CLUSTER_ROLE, CLUSTER_STATUS FROM V$OB_STANDBY_STATUS; +------------+--------------+------------------+----------------+ | CLUSTER_ID | CLUSTER_NAME | CLUSTER_ROLE | CLUSTER_STATUS | +------------+--------------+------------------+----------------+ | 2 | obcluster | PHYSICAL STANDBY | VALID | | 3 | obcluster | PHYSICAL STANDBY | VALID | +------------+--------------+------------------+----------------+ 2 rows in setRun the following command to obtain the protection mode and protection level of the current cluster:
obclient> SELECT PROTECTION_MODE, PROTECTION_LEVEL FROM V$OB_CLUSTER; +--------------------+--------------------+ | PROTECTION_MODE | PROTECTION_LEVEL | +--------------------+--------------------+ | MAXIMUM PROTECTION | MAXIMUM PROTECTION | +--------------------+--------------------+ 1 row in setIn the example:
- For more information, see Protection mode and protection level.
Select a standby cluster to be switched to the primary role
When multiple standby clusters exist, select an appropriate one as the target cluster to be switched to the primary role by considering the following aspects:
Region
Hardware configurations, including the CPUs and I/O bandwidth
Synchronization progress
In maximum performance mode, a longer latency of the standby cluster to the primary cluster means longer switch time and more severe data loss after a failover.
Protection mode and protection level
In maximum protection or maximum availability mode, only a standby cluster in
SYNCmode can be switched to the primary role. During a failover, an appropriate failover command must be selected based on the protection mode and the protection level.
To view information about clusters, perform the following operations:
Query the
CURRENT_SCNfield in theV$OB_CLUSTERview of each cluster to obtain the synchronization progress of the cluster.CURRENT_SCNis a UNIX timestamp indicating the current synchronization progress. It is an integer value in microseconds.For example, you can log on to standby cluster 2 and run the following SQL command to query its synchronization progress:
obclient> SELECT CURRENT_SCN, USEC_TO_TIME(CURRENT_SCN) AS SYNC_TS FROM V$OB_CLUSTER; +------------------+----------------------------+ | CURRENT_SCN | SYNC_TS | +------------------+----------------------------+ | 1596354672506590 | 2020-08-02 15:51:12.506590 | +------------------+----------------------------+ 1 row in setA greater value of
CURRENT_SCNindicates a lower synchronization latency of the standby cluster. A standby cluster with a low synchronization latency can be selected as the target standby cluster to be switched to the primary role. You can subtract the value ofCURRENT_SCNof the standby cluster from the value ofCURRENT_SCNof the primary cluster to obtain the synchronization latency of the standby cluster.Query the
V$OB_STANDBY_STATUSview of the primary cluster to view the configurations and protection level of each standby cluster.obclient> SELECT CLUSTER_ID, PROTECTION_LEVEL, REDO_TRANSPORT_OPTIONS FROM V$OB_STANDBY_STATUS; +------------+---------------------+------------------------------+ | CLUSTER_ID | PROTECTION_LEVEL | REDO_TRANSPORT_OPTIONS | +------------+---------------------+------------------------------+ | 2 | MAXIMUM PROTECTION | SYNC NET_TIMEOUT = 30000000 | | 3 | MAXIMUM PERFORMANCE | ASYNC NET_TIMEOUT = 30000000 | +------------+---------------------+------------------------------+ 2 rows in setIn the example:
REDO_TRANSPORT_OPTIONSindicates the log transfer configurations of each standby cluster.SYNCindicates a standby cluster in SYNC mode.ASYNCindicates a standby cluster in ASYNC mode.PROTECTION_LEVELindicates the protection level of each standby cluster. It is equivalent to thePROTECTION_LEVELfield in theV$OB_CLUSTERview.