1. 程式人生 > >oracle DG 啟動和關閉順序

oracle DG 啟動和關閉順序

啟動順序:先啟動備庫,後啟動主庫

關閉順序:先關閉主庫,後關閉備庫

1、正確開啟備庫和主庫

備庫:

SQL> STARTUP MOUNT;

SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  DISCONNECT FROM SESSION;

主庫:

SQL> STARTUP MOUNT;

SQL> ALTER DATABASE ARCHIVELOG;

SQL> ALTER DATABASE OPEN;


2、正確關閉順序

主庫

SQL>SHUTDOWN IMMEDIATE;


備庫:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;


SQL>SHUTDOWN IMMEDIATE;

############################################################################

1.  主備切換

 1) 主庫切換為備庫

 alter database commit to switchover to physical standby;

主庫有會話連線的時候

alter database commit to switchover to physical standby with session shutdown;

shutdown immediate

startup nomount

alter database mount standby database;

alter database recover managed standby database disconnect from session;

2) 從庫切換為主庫

alter database commit to switchover to primary;

shutdown immediate; 

startup

alter system switch logfile;

3) 從庫開啟只讀實時應用模式

alter database recover managed standby databasecancel; 

alter database open;

alter database recover managed standby database using current logfile disconnect;

4) 檢查切換狀態

select open_mode,database_role,db_unique_name from v$database;