【DataGuard】OracleDataGuard數(shù)據(jù)保護模式切換

Oracle 11g DataGuard 數(shù)據(jù)保護模式切換

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

【實驗圖例】


【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換



【實驗環(huán)境】

操作系統(tǒng):Red Hat Enterprise Linux Server release 5.4
數(shù)據(jù)庫:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0

【主庫、物理備庫結(jié)構(gòu)信息】

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換


【實驗過程】


①、最高性能 升級 最高可用


(1)查看數(shù)據(jù)庫當前保護模式:最高性能模式
select database_role,protection_mode,protection_level from v$database;
主庫 Primary : 

創(chuàng)新互聯(lián)專注于河西網(wǎng)站建設服務及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供河西營銷型網(wǎng)站建設,河西網(wǎng)站制作、河西網(wǎng)頁設計、河西網(wǎng)站官網(wǎng)定制、微信小程序開發(fā)服務,打造河西網(wǎng)絡公司原創(chuàng)品牌,更為您提供河西網(wǎng)站排名全網(wǎng)營銷落地服務。

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換
物理備庫 Physical Standby
【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

查看日志傳輸方式
當前在最大性能模式下,日志傳輸方式為ARCH ASYNC,arch進程異步傳輸歸檔的方式。
【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

(2)修改主庫日志傳輸模式
要升級為最高通過修改初始化參數(shù)文件中遠程歸檔參數(shù),講日志傳輸模式改為LGWR SYNC AFIRM,即lgwr進程同步傳輸redo日志的方式。

vim $ORACLE_HOME/dbs/initBJ.ora

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換
主庫正常關(guān)庫后開庫。

shutdown immediate;

startup;


(3)備庫添加standby logfilegroup
首先查看當前日志組個數(shù)、大小、文件位置

select sequence#,group#,bytes/1024/1024 MB from v$log;
【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

select member from v$logfile;

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

備庫要添加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;

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

添加完成后查看,standby logfile group 已經(jīng)添加
【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

(4)切換數(shù)據(jù)保護模式為最高可用

alter database set standby database to maximize availability;
【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換
查看當前主、備庫數(shù)據(jù)保護模式,已經(jīng)是最高可用模式。

select database_role,protection_mode,protection_level from v$database;

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換
【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換



②、最高可用 升級 最大保護

(1)查看當前數(shù)據(jù)庫保護模式:最高可用模式

select database_role,protection_mode,protection_level from v$database;

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

(2)設置數(shù)據(jù)庫保護模式為最大保護

alter database set standby database to maximize protection;
查看數(shù)據(jù)庫當前保護模式,已經(jīng)升級成功:最大保護模式

select database_role,protection_mode,protection_level from v$database;

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換




③、最大保護 轉(zhuǎn) 最高可用 (降級)


查詢當前保護模式狀態(tài):最大保護模式
設置保護模式為最高可用
再次查詢,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;

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

④、最高可用 轉(zhuǎn) 最高性能 (降級)


查詢當前保護模式狀態(tài):最高可用模式
設置保護模式為最高性能
再次查詢,已成功切換為:最高性能模式。

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;

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換



⑤、最高性能 升級 最大保護

查詢當前數(shù)據(jù)庫保護模式:最高性能模式

select database_role,open_mode,protection_mode,protection_level from v$database;

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

設置數(shù)據(jù)保護模式為最大保護報錯,【ORA-01126】:database must be mounted in this instance and not open in any instance;
要求在mounted狀態(tài)操作,且任何實例都不能處于open狀態(tài)。

alter database set standby database to maximize protection;

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

正常關(guān)庫,把庫起到mount狀態(tài)

shutdown immediate;

startup mount;

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

在mount狀態(tài),設置數(shù)據(jù)庫保護模式,可以切換,因處于mount狀態(tài),當先保護模式顯示unprotected.

select database_role,protection_mode,protection_level from v$database;

alter database open;
【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換

open狀態(tài)后再次查看,已成功升級為最大保護模式
【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換



⑥、最大保護 轉(zhuǎn) 最高性能 (降級)


查看當前數(shù)據(jù)庫保護模式:最大保護模式
設置數(shù)據(jù)庫保護模式為最高性能
查看已經(jīng)設置成功,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;

【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換


【實驗總結(jié)】

1、最高性能模式既可以使用ARCH方式傳遞日志,也可以使用LGWR方式傳遞,在升級到更高級別保護模式時,需使用LGWR方式,且需要在備庫創(chuàng)建standby日志組。
2、三種保護模式進行切換時,最高性能升級到最大保護模式(⑤),需先把數(shù)據(jù)庫重啟到mounted狀態(tài)才能操作。其他情況(①②③④⑥)相互切換時,可以直接進行。

根據(jù)實驗結(jié)論,在生產(chǎn)環(huán)境下如果需要從最高性能模式升級為最大保護模式,可先從最高性能模式升級最高可用模式,再由最高可用模式升級為最大保護模式。
如下圖,通過①②分步升級的方式代替⑤直接升級,避免了重啟到mounted狀態(tài)對生產(chǎn)環(huán)境下業(yè)務造成的影響。


【DataGuard】Oracle DataGuard 數(shù)據(jù)保護模式切換




                                                                                         呂星昊 
                                                                                         2014.8.9

本文題目:【DataGuard】OracleDataGuard數(shù)據(jù)保護模式切換
文章出自:http://www.muchs.cn/article42/jsodhc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、手機網(wǎng)站建設、App開發(fā)響應式網(wǎng)站、小程序開發(fā)品牌網(wǎng)站建設

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務器托管