溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

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

發(fā)布時(shí)間:2020-08-16 01:58:19 來(lái)源:ITPUB博客 閱讀:241 作者:renzhuangzhuang 欄目:關(guān)系型數(shù)據(jù)庫(kù)
Oracle 11g DataGuard 數(shù)據(jù)保護(hù)模式切換

Data Guard 提供三種數(shù)據(jù)保護(hù)模式:最大保護(hù)(Maximum Protection),最高可用(Maximum Availability)和 最高性能(Maximum Performance)。
如果按照對(duì)數(shù)據(jù)的保護(hù)程度或者說(shuō)主從庫(kù)數(shù)據(jù)的同步性 由低到高排序,三種保護(hù)模式的順序應(yīng)該是:最高性能、最高可用、最大保護(hù) 。
本文通過(guò)實(shí)驗(yàn)?zāi)M三種數(shù)據(jù)保護(hù)模式進(jìn)行相互切換六個(gè)場(chǎng)景,對(duì)比保護(hù)模式的升級(jí)、切換過(guò)程。

【實(shí)驗(yàn)圖例】


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



【實(shí)驗(yàn)環(huán)境】

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

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

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


【實(shí)驗(yàn)過(guò)程】


①、最高性能 升級(jí) 最高可用


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

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

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

(2)修改主庫(kù)日志傳輸模式

要升級(jí)為最高通過(guò)修改初始化參數(shù)文件中遠(yuǎn)程歸檔參數(shù),講日志傳輸模式改為L(zhǎng)GWR SYNC AFIRM,即lgwr進(jìn)程同步傳輸redo日志的方式。

vim $ORACLE_HOME/dbs/initBJ.ora

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

shutdown immediate;

startup;


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

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

select member from v$logfile;

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

備庫(kù)要添加4個(gè)standby 日志組,比普通日志組多一個(gè)。

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ù)保護(hù)模式切換

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

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

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

select database_role,protection_mode,protection_level from v$database;

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



②、最高可用 升級(jí) 最大保護(hù)

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

select database_role,protection_mode,protection_level from v$database;

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

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

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

select database_role,protection_mode,protection_level from v$database;

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




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


查詢(xún)當(dāng)前保護(hù)模式狀態(tài):最大保護(hù)模式
設(shè)置保護(hù)模式為最高可用
再次查詢(xún),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ù)保護(hù)模式切換


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


查詢(xún)當(dāng)前保護(hù)模式狀態(tài):最高可用模式
設(shè)置保護(hù)模式為最高性能
再次查詢(xún),已成功切換為:最高性能模式。

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ù)保護(hù)模式切換



⑤、最高性能 升級(jí) 最大保護(hù)

查詢(xún)當(dāng)前數(shù)據(jù)庫(kù)保護(hù)模式:最高性能模式

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

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

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

alter database set standby database to maximize protection;

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

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

shutdown immediate;

startup mount;

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

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

select database_role,protection_mode,protection_level from v$database;

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

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



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


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


【實(shí)驗(yàn)總結(jié)】

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

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


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




                                                                                         呂星昊 
                                                                                         2014.8.9
向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI