oracle 12cR2 DG 多租戶之switchower切換

Switchover 角色切換

(一) 主、備角色互換
(01). 主庫操做:
1) 查看狀態
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS

TO STANDBY
2) 切換狀態到standby
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
SQL> SHUTDOWN IMMEDIATE;
3) 置於Open Read Real Time恢復狀態
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1660944384 bytes
Fixed Size 8793448 bytes
Variable Size 989856408 bytes
Database Buffers 654311424 bytes
Redo Buffers 7983104 bytes
Database mounted.

SQL> ALTER DATABASE OPEN;
Database altered.

SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED

2 PDB$SEED READ ONLY NO
3 NAILPDB1 MOUNTED
4 PDB2 MOUNTED
5 PDB3 MOUNTED
SQL> alter pluggable database all open;
Pluggable database altered.

SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED

2 PDB$SEED READ ONLY NO
3 NAILPDB1 READ ONLY NO
4 PDB2 READ ONLY NO
5 PDB3 READ ONLY NO
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
Database altered.

SQL> select open_mode,database_role,protection_mode,protection_level from v$database;
OPEN_MODE DATABASE_ROLE PROTECTION_MODE PROTECTION_LEVEL

READ ONLY WITH APPLY PHYSICAL STANDBY MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY

(02). 備庫操做:
如下在備庫操做(Backup)
01). 查看狀態
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS

TO PRIMARY
02). 備庫切到Primary角色
SQL>ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
數據庫已更改。
03). 打開數據庫
SQL>ALTER DATABASE OPEN;
數據庫已更改。
SQL> select open_mode from v$database;
OPEN_MODE

READ WRITE
SQL> select open_mode,database_role,protection_mode,protection_level from v$database;
OPEN_MODE DATABASE_ROLE PROTECTION_MODE PROTECTION_LEVEL

READ WRITE PRIMARY MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY

SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED

2 PDB$SEED READ ONLY NO
3 NAILPDB1 MOUNTED
4 PDB2 MOUNTED
5 PDB3 MOUNTED
SQL> alter pluggable database all open;
Pluggable database altered.

SQL> 
SQL> show pdbs;

CON_ID CON_NAME OPEN MODE RESTRICTED

2 PDB$SEED READ ONLY NO
3 NAILPDB1 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
SQL>

根據上述日誌能夠看出,切換命令是在CDB中執行的,且全部PDB也會被切換。sql

相關文章
相關標籤/搜索