Purpose
You can use this statement to switch primary and standby tenant roles: losslessly switch a primary tenant to a standby tenant, or switch a standby tenant to a primary tenant.
Syntax
ALTER SYSTEM SWITCHOVER TO {STANDBY | PRIMARY} [TENANT tenant_name] [VERIFY];
Note
- The
TENANT tenant_nameparameter is required when the system tenant executes this command. - A user tenant can only execute this command for itself.
Parameters
Parameter |
Description |
|---|---|
| STANDBY | Losslessly switches the primary tenant to the STANDBY role. |
| PRIMARY | Switches the standby tenant to the PRIMARY role. |
| tenant_name | The name of the primary or standby tenant. |
| VERIFY |
NoteFor OceanBase Database V4.2.1, this feature is supported starting from V4.2.1 BP8. SWITCHOVER command are met.
Notice
|
Examples
Execute the primary-to-standby switchover command for the primary tenant to change it to a standby tenant named tenant1, and verify that the primary tenant has been switched to a standby tenant, with TENANT_ROLE changed to STANDBY and SWITCHOVER_STATUS changed to NORMAL.
obclient> ALTER SYSTEM SWITCHOVER TO STANDBY TENANT tenant1;
Query OK, 0 rows affected
obclient> SELECT TENANT_NAME,TENANT_TYPE,TENANT_ROLE,SWITCHOVER_STATUS FROM DBA_OB_TENANTS
WHERE TENANT_NAME='tenant1';
+---------------------+-------------+-------------+-------------------+
| TENANT_NAME | TENANT_TYPE | TENANT_ROLE | SWITCHOVER_STATUS |
+---------------------+-------------+-------------+-------------------+
| tenant1 | USER | STANDBY | NORMAL |
+---------------------+-------------+-------------+-------------------+
1 row in set
References
For more information about the usage of the SWITCHOVER command, see Switchover.