Purpose
You can use this statement to convert a primary cluster into a standby cluster.
When a failover occurs, if there are two clusters, you can use CONVERT to covert the original primary cluster to a standby cluster. The purpose is to establish a primary/standby relationship between the original and new primary clusters.
Notice
If no other clusters are available, the current cluster cannot be converted to a standby cluster.
Syntax
ALTER SYSTEM CONVERT TO PHYSICAL STANDBY;
Examples
Connect to the original primary cluster after a lossless failover.
Restore the original primary cluster.
Before the original primary cluster is restored, all servers in the original primary cluster must be disabled. This can ensure that data of the original primary cluster is consistent with that of the new primary cluster.
All servers in the original primary cluster must start by using the -m disabled_cluster option during the restore of the original primary cluster. After the original primary cluster is started, it automatically enters the
DISABLEDstatus. The original primary cluster in theDISABLEDstatus does not receive data writes or generate new logs. This ensures that the original primary cluster is in the same state as the new primary cluster. If all servers in the original primary cluster do not start by using the -m disabled_cluster option, the original primary cluster will generate new logs, causing a connection failure or data checksum error.Specify the
-m disabled_clusterparameter on all servers of the original primary cluster to start the OBServer node.bin/observer -m disabled_clusterAfter the original primary cluster is restored, it is in the
DISABLEDstate but its role isPRIMARY.obclient> SELECT CLUSTER_ID, CLUSTER_ROLE, CLUSTER_STATUS FROM V$OB_CLUSTER; +------------+--------------+----------------+ | CLUSTER_ID | CLUSTER_ROLE | CLUSTER_STATUS | +------------+--------------+----------------+ | 1 | PRIMARY | DISABLED | +------------+--------------+----------------+ 1 row in setSwitch the original primary cluster to the standby role.
Execute the following statement on the original primary cluster to switch it to the standby role:
obclient> ALTER SYSTEM CONVERT TO PHYSICAL STANDBY;Execute the following statement to verify the role of the original primary cluster:
obclient> SELECT CLUSTER_ID, CLUSTER_ROLE, CLUSTER_STATUS FROM V$OB_CLUSTER; +------------+------------------+----------------+ | CLUSTER_ID | CLUSTER_ROLE | CLUSTER_STATUS | +------------+------------------+----------------+ | 1 | PHYSICAL STANDBY | DISABLED | +------------+------------------+----------------+ 1 row in setIn the new primary cluster, enable synchronization to the original primary cluster, which is now a standby cluster.
Log on to the new primary cluster and execute the following statement to enable synchronization to standby clusters:
obclient> ALTER SYSTEM ENABLE CLUSTER SYNCHRONIZATION 'obcluster' CLUSTER_ID=1;Verify that synchronization is enabled.
obclient> SELECT CLUSTER_ID, CLUSTER_ROLE, CLUSTER_STATUS FROM V$OB_STANDBY_STATUS; +------------+------------------+----------------+ | CLUSTER_ID | CLUSTER_ROLE | CLUSTER_STATUS | +------------+------------------+----------------+ | 1 | PHYSICAL STANDBY | VALID | +------------+------------------+----------------+ 1 row in set
Connect to the original primary cluster after a lossy failover.
Delete the original primary cluster or other standby clusters from the new primary cluster, and clear the data of the original primary cluster or other standby clusters.
In the new primary cluster, execute the following statement to query information about other clusters.
obclient> SELECT CLUSTER_ID, CLUSTER_ROLE, CLUSTER_STATUS FROM V$OB_STANDBY_STATUS; +------------+------------------+----------------+ | CLUSTER_ID | CLUSTER_ROLE | CLUSTER_STATUS | +------------+------------------+----------------+ | 1 | PHYSICAL STANDBY | DISABLED | +------------+------------------+----------------+ 1 row in setIn the new primary cluster, execute the following statement to delete information about other clusters:
obclient> ALTER SYSTEM REMOVE CLUSTER obcluster CLUSTER_ID = 1; Query OK, 0 rows affectedManually clear the processes and data of the other clusters.
Create standby clusters on the servers hosting the other clusters and rebuild the primary/standby relationship.
Notice
After a lossy failover, the system automatically initiates a major compaction. You need to wait for the major compaction to complete and then create a standby cluster.
You can execute an SQL statement to add a standby cluster. When you add a standby cluster, ensure that the ````cluster ID assigned to the standby cluster is unique.After the new standby cluster is synchronized in real time, switch the primary and standby roles.