【DataGuard】Oracle DataGuard 資料保護模式切換
Data Guard 提供三種資料保護模式:最大保護(Maximum Protection),最高可用(Maximum Availability)和 最高效能(Maximum Performance)。
如果按照對資料的保護程度或者說主從庫資料的同步性 由低到高排序,三種保護模式的順序應該是:最高效能、最高可用、最大保護 。
本文通過實驗模擬三種資料保護模式進行相互切換六個場景,對比保護模式的升級、切換過程。
【實驗圖例】

【實驗環境】
作業系統:Red Hat Enterprise Linux Server release 5.4資料庫:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
【主庫、物理備庫結構資訊】

【實驗過程】
①、最高效能 升級 最高可用
(1)檢視資料庫當前保護模式:最高效能模式
select
database_role,protection_mode,protection_level from v$database;
主庫 Primary :

物理備庫 Physical Standby

檢視日誌傳輸方式
當前在最大效能模式下,日誌傳輸方式為ARCH ASYNC,arch程式非同步傳輸歸檔的方式。

(2)修改主庫日誌傳輸模式
要升級為最高通過修改初始化引數檔案中遠端歸檔引數,講日誌傳輸模式改為LGWR SYNC AFIRM,即lgwr程式同步傳輸redo日誌的方式。
vim $ORACLE_HOME/dbs/initBJ.ora

主庫正常關庫後開庫。
shutdown immediate;
startup;
(3)備庫新增standby logfilegroup
首先檢視當前日誌組個數、大小、檔案位置
select sequence#,group#,bytes/1024/1024 MB from v$log;
select member from v$logfile;
備庫要新增4個standby 日誌組,比普通日誌組多一個。
alter database add standby logfile group 4 '/u02/oradata/sh/redo04.std' size 50m;
alter database add standby logfile group 5 '/u02/oradata/sh/redo05.std' size 50m;
alter database add standby logfile group 6 '/u02/oradata/sh/redo06.std' size 50m;
alter database add standby logfile group 7 '/u02/oradata/sh/redo07.std' size 50m;

新增完成後檢視,standby logfile group 已經新增

(4)切換資料保護模式為最高可用
alter database set standby database
to maximize availability;
檢視當前主、備庫資料保護模式,已經是最高可用模式。
select database_role,protection_mode,protection_level from v$database;


②、最高可用 升級 最大保護
(1)檢視當前資料庫保護模式:最高可用模式select database_role,protection_mode,protection_level from v$database;

(2)設定資料庫保護模式為最大保護
alter database set standby database
to maximize protection;
檢視資料庫當前保護模式,已經升級成功:最大保護模式
select database_role,protection_mode,protection_level from v$database;

③、最大保護 轉 最高可用 (降級)
查詢當前保護模式狀態:最大保護模式
設定保護模式為最高可用
再次查詢,protection_level 已成功切換為:最高可用模式。
select database_role,open_mode,protection_mode,protection_level from v$database;
alter database set standby database to maximize availability;
select database_role,open_mode,protection_mode,protection_level from v$database;

④、最高可用 轉 最高效能 (降級)
查詢當前保護模式狀態:最高可用模式
設定保護模式為最高效能
再次查詢,已成功切換為:最高效能模式。
select database_role,protection_mode,protection_level from v$database;
alter database set standby database to maximize performance;
select database_role,protection_mode,protection_level from v$database;

⑤、最高效能 升級 最大保護
查詢當前資料庫保護模式:最高效能模式select database_role,open_mode,protection_mode,protection_level from v$database;

設定資料保護模式為最大保護報錯,【ORA-01126】:database must be mounted in this instance and not open in any instance;
要求在mounted狀態操作,且任何例項都不能處於open狀態。
alter database set standby database to maximize protection;
shutdown immediate;
startup mount;

在mount狀態,設定資料庫保護模式,可以切換,因處於mount狀態,當先保護模式顯示unprotected.
select database_role,protection_mode,protection_level from v$database;
alter database
open;

⑥、最大保護 轉 最高效能 (降級)
檢視當前資料庫保護模式:最大保護模式
設定資料庫保護模式為最高效能
檢視已經設定成功,protection_level 已變成最高效能模式。
select database_role,protection_mode,protection_level from v$database;
alter database set standby database to maximize performance;
select database_role,protection_mode,protection_level from v$database;

【實驗總結】
1、最高效能模式既可以使用ARCH方式傳遞日誌,也可以使用LGWR方式傳遞,在升級到更高階別保護模式時,需使用LGWR方式,且需要在備庫建立standby日誌組。2、三種保護模式進行切換時,最高效能升級到最大保護模式(⑤),需先把資料庫重啟到mounted狀態才能操作。其他情況(①②③④⑥)相互切換時,可以直接進行。
根據實驗結論,在生產環境下如果需要從最高效能模式升級為最大保護模式,可先從最高效能模式升級最高可用模式,再由最高可用模式升級為最大保護模式。
如下圖,通過①②分步升級的方式代替⑤直接升級,避免了重啟到mounted狀態對生產環境下業務造成的影響。

呂星昊
2014.8.9
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29475508/viewspace-1248530/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 11.2.0.4 physical dataguard和snapshot dataguard切換Oracle
- 【DATAGUARD】Oracle Dataguard物理備庫切換最佳實踐(sqlplus)OracleSQL
- oracle11g dataguard切換Oracle
- DATAGUARD失敗切換
- DATAGUARD強行切換
- Oracle DataGuard 主備切換 (switchover) oracle11gOracle
- 【DATAGUARD】Oracle Dataguard nologging 塊修復Oracle
- ORACLE 12C DATAGUARD環境搭建和主從切換Oracle
- 基於單機的DataGuard切換文件
- 【DATAGUARD】Oracle Dataguard體系架構詳解Oracle架構
- Oracle資料庫(DataGuard)遷移方案(上)Oracle資料庫
- Oracle資料庫(DataGuard)遷移方案(中)Oracle資料庫
- Oracle資料庫(DataGuard)遷移方案(下)Oracle資料庫
- 【DATAGUARD】Oracle 通過Dataguard指定恢復時間用於找回丟失資料Oracle
- DataGuard---->物理StandBy的角色切換之switchover
- 基於多種場景DataGuard切換方案
- 【DATAGUARD】Oracle19c dataguard新特性及部署Oracle
- oracle dataguard broker 配置Oracle
- Oracle dataguard failover 實戰OracleAI
- Oracle 單機配置DataGuardOracle
- 【Dataguard】Oracle多租戶環境對Dataguard的影響Oracle
- oracle 19c dataguard silent install (oracle 19c dataguard 靜默安裝)Oracle
- Oracle之11g DataGuardOracle
- Oracle 11.2 DataGuard RAC To RAC搭建Oracle
- DATAGUARD監控,保護和自動修復最佳實踐
- Oracle Dataguard故障轉移(failover)操作OracleAI
- 7 Oracle DataGuard 命令列參考Oracle命令列
- 【Dataguard】DataGuard運維注意事項運維
- 物理DataGuard客戶端無縫切換--客戶端TAF 配置客戶端
- 【DATAGUARD】Oracle21c Dataguard建立注意事項及主要引數介紹Oracle
- Oracle資料庫由dataguard備庫引起的log file sync等待Oracle資料庫
- Oracle資料庫歸檔模式的切換ELOracle資料庫模式
- 【DATAGUARD】Oracle19c Data Guard BrokerOracle
- Oracle 11.2.0.4 Dataguard兩則故障處理Oracle
- 【DATAGUARD】Dataguard遠端同步配置最佳實踐
- Oracle dataguard報錯:Error 1017 received logging on to the standbyOracleError
- 關於dataguard需要查詢的資料字典
- Oracle 11g dataguard 配置簡約步驟Oracle
- RAC+ASM+DATAGUARDASM