Oracle DataGuard 主備切換 (switchover) oracle11g
Oracle DataGuard主備切換(switchover)
首先確認現在的dataguard是否正確
主庫
SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS,protection_level FROM V$DATABASE; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS PROTECTION_LEVEL -------------------- ---------------- -------------------- -------------------- READ WRITE PRIMARY TO STANDBY MAXIMUM PERFORMANCE
備庫
SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS,protection_level FROM V$DATABASE; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS PROTECTION_LEVEL -------------------- ---------------- -------------------- -------------------- READ ONLY WITH APPLY PHYSICAL STANDBY NOT ALLOWED MAXIMUM PERFORMANCE
備庫為以下狀態,說明現階段dataguard正常
READ ONLY WITH APPLY
(一)將主庫切換為物理備庫
STEP1:檢視主庫狀態
SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS,protection_level FROM V$DATABASE; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS PROTECTION_LEVEL -------------------- ---------------- -------------------- -------------------- READ WRITE PRIMARY TO STANDBY MAXIMUM PROTECTION
注意:需要檢查SWITCHOVER_STATUS引數,如果值為"SESSION ACTIVE"或者"TO STANDBY", 則主資料庫角色可以切換為備庫角色。
STEP2:將其切換到備庫,切換後,資料庫會關閉
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY [WITH SESSION SHUTDOWN];
注意:如果上一步的SWITCH_STATUS引數值為"TO STANDBY",則 WITH SESSION SHUTDOWN 可以省略。
STEP3:啟動到mount狀態
SQL> STARTUP MOUNT
注意:11.2.0.4版本及其以上版本不需要執行"SHUTDOWN ABORT",因為資料庫已經在STEP2命令中關閉了。
(二) 將備庫切換成主庫並啟動到open
STEP1:檢視備庫狀態
SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS,protection_level FROM V$DATABASE; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS PROTECTION_LEVEL -------------------- ---------------- -------------------- -------------------- READ ONLY PHYSICAL STANDBY RECOVERY NEEDED MAXIMUM PROTECTION
注意:需要檢查SWITCH_STATUS引數,如果值為"SESSION ACTIVE"或"TO PRIMARY",則備庫可以切換為主庫。
此處SWITCH_STATUS引數為 RECOVERY NEEDED,或者NOT ALLOWED 需要執行
SQL> RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION; Media recovery complete. SQL>
再次檢查備庫狀態
SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS,protection_level FROM V$DATABASE; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS PROTECTION_LEVEL -------------------- ---------------- -------------------- -------------------- READ ONLY WITH APPLY PHYSICAL STANDBY TO PRIMARY MAXIMUM PROTECTION
此時已經是TO PRIMARY
STEP2: 切換到主庫
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY [WITH SESSION SHUTDOWN];
注意:如果上一步的SWITCH_STATUS引數值為"TO PRIMARY",則 WITH SESSION SHUTDOWN 可以省略。
STEP3: 此時資料庫為mount狀態,需開啟資料庫
SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS FROM V$DATABASE; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS FOR DATAGUAR GUARD_S -------------------- ---------------- -------------------- --- -------- ------- MOUNTED PRIMARY NOT ALLOWED YES DISABLED NONE SQL> ALTER DATABASE OPEN ; SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS FROM V$DATABASE; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS FOR DATAGUAR GUARD_S -------------------- ---------------- -------------------- --- -------- ------- READ WRITE PRIMARY TO STANDBY YES DISABLED NONE
(三)新的備庫開啟日誌應用
SQL> ALTER DATABASE OPEN; SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT ;
或者
SQL> alter database recover managed standby database disconnect from session;
###################兩種注意點#########################################################################
啟動redo 應用
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
啟動實時應用
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
提示:disconnect from session子句並非必須,該子句用於指定啟動完應用後自動退出到命令運算子前,
如果不指定的話,當前session 就會一直停留處理redo 應用,如果想做其它操作,就只能新建一個連線。
兩者切換需要用到語句
SQL> alter database recover managed standby database cancel;
如果是啟動的實時應用,主庫插入一條語句,備庫就能查詢到
如果是啟用的redo應用,備庫需要過一會才會查詢到。
#######################################################################################################
檢視備庫狀態
SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS,protection_level FROM V$DATABASE; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS PROTECTION_LEVEL -------------------- ---------------- -------------------- -------------------- READ ONLY WITH APPLY PHYSICAL STANDBY NOT ALLOWED MAXIMUM PROTECTION
參考文件:https://www.cnblogs.com/lijiaman/p/13335406.html
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70004783/viewspace-2789023/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 10g DataGuard物理主備切換-switchover與failoverOracle 10gAI
- Oracle DataGuard switchover切換一例Oracle
- oracle11g dataguard切換Oracle
- 【DataGuard】10g物理standby主備switchover方式切換詳述
- dataguard主備switchover互切實驗及理解
- 備庫的切換狀態為SWITCHOVER PENDING時進行dataguard主備庫角色切換
- 【DG】Data Guard主備庫Switchover切換
- DataGuard主備庫切換步驟
- 再次使用DGbroker做switchover主備切換
- 【DATAGUARD】物理dg的switchover切換(五)
- oracle11g dataguard完全手冊--switchoverOracle
- openGauss主備切換之switchover與failoverAI
- 【DataGuard】Oracle 11g DataGuard 角色轉換(一)物理備庫SwitchoverOracle
- Oracle 12c Data guard 物理主備庫正常切換(switchover)流程Oracle
- Oracle 11g Data guard 物理主備庫正常切換(switchover)流程Oracle
- DataGuard---->物理StandBy的角色切換之switchover
- oracle dataguard 切換Oracle
- DATAGUARD在做SWITCHOVER切換時遇到問題總結
- Oracle10G Dataguard 多個備庫 - 主庫和物理備庫的切換Oracle
- DataGuard切換(主庫為Rac+備庫為Rac)
- 實戰dataguard主從切換
- Oracle 單機切換為主備Oracle
- dataguard角色轉換—switchover
- 【DATAGUARD】Oracle Dataguard物理備庫切換最佳實踐(sqlplus)OracleSQL
- DATA GUARD物理備庫的SWITCHOVER切換
- Oracle DataGuard切換步驟Oracle
- oracle 之dataguard standby 切換Oracle
- 物理dataguard 正常切換 角色轉換,switchover_status 狀態改變
- DG中備庫為SWITCHOVER PENDING時是否能進行主備切換
- 【DataGuard】使用Grid Control對Oracle物理Data Guard進行Switchover切換Oracle
- RAC和Dataguard環境下主備庫切換演練模板
- 物理dataguard 正常切換 腳色轉換,switchover_status 狀態改變
- ORACLE 12C DATAGUARD環境搭建和主從切換Oracle
- 【DataGuard】Oracle DataGuard 資料保護模式切換Oracle模式
- dataguard手動switchover切換步驟及注意的問題 轉
- oracle 之dataguard主庫系統崩潰之物理備庫切主庫Oracle
- 主備切換(failover)AI
- Dataguard物理Standby Switchover 角色轉換