【DataGuard】Oracle 11g DataGuard 新特性之 Snapshot Standby Database
Oracle 11g DataGuard 的Snapshot Standby資料庫功能,可以讓物理備庫從只讀狀態 切換到可讀寫狀態。
在snapshot standby狀態下,備庫可以進行讀寫操作,同時備庫還會正常接收主庫的歸檔和日誌資訊,但不會應用這些redo日誌。
當備庫讀寫狀態下任務完成後,還可以從Snapshot Standby資料庫角色切換回Physical standby備庫角色,恢復與主庫資料同步。
切換回物理備庫後,在Snapshot standby狀態下寫入備庫的資料將不再存在。
【實驗環境】
Red Hat Enterprise Linux Server release 5.4
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
【DG主庫、物理備庫結構資訊】
【實驗過程】
主庫 Primary database:綠色物理備庫 Physical standby database:黃色
1、切換前準備
1.1、檢視當前備庫模式
sys@DGDB>select database_role, open_mode, protection_mode, protection_level from v$database;
1.2、主備庫檢視測試表資訊
1.3、確認備庫閃回區已設定
未設定閃回區報錯
設定閃回區後檢視
sys@DGDB>show parameter db_recovery
1.4、備庫取消日誌應用
在日誌應用狀態轉換報錯
備庫取消日誌應用
sys@DGDB>alter database recover managed standby database cancel;
sys@DGDB>select database_role, open_mode, protection_mode, protection_level from v$database;
2、physical standby 切換為 snapshot standby
2.1、備庫轉換為snapshot standby
sys@DGDB>alter database convert to snapshot standby; -- 轉化成 snapshot standby
檢視當前備庫狀態 snapshot standby
sys@DGDB>select
database_role, open_mode, protection_mode, protection_level from v$database;
轉換過程中告警日誌
Sun Aug 24 01:18:07 2014 alter database convert to snapshot standby Starting background process RVWR Sun Aug 24 01:18:07 2014 RVWR started with pid=27, OS id=17153 Allocated 3981120 bytes in shared pool for flashback generation buffer Created guaranteed restore point SNAPSHOT_STANDBY_REQUIRED_08/24/2014 01:18:07 krsv_proc_kill: Killing 3 processes (all RFS) All dispatchers and shared servers shutdown CLOSE: killing server sessions. CLOSE: all sessions shutdown successfully. Sun Aug 24 01:18:10 2014 SMON: disabling cache recovery Begin: Standby Redo Logfile archival End: Standby Redo Logfile archival RESETLOGS after incomplete recovery UNTIL CHANGE 1216097 Resetting resetlogs activation ID 2198976699 (0x8311b8bb) Online log /u02/oradata/sh/redo01.log: Thread 1 Group 1 was previously cleared Online log /u02/oradata/sh/redo02.log: Thread 1 Group 2 was previously cleared Online log /u02/oradata/sh/redo03.log: Thread 1 Group 3 was previously cleared Standby became primary SCN: 1216095 Sun Aug 24 01:18:11 2014 Setting recovery target incarnation to 3 CONVERT TO SNAPSHOT STANDBY: Complete - Database mounted as snapshot standby Completed: alter database convert to snapshot standby |
2.2、snapshot standby開庫,可讀寫
sys@DGDB>alter database open;
sys@DGDB>select database_role, open_mode, protection_mode, protection_level from v$database;
2.3、對測試表進行插入操作
現在可以 讀寫操作 standby database
sys@DGDB>insert into lvxinghao.test select * from scott.emp;
sys@DGDB>select count(*) from lvxinghao.test;
3、snapshot standby 切回 日誌應用狀態
3.1、備庫重啟到mount狀態
idle>startup mount force;
idle>select database_role, open_mode, protection_mode, protection_level from v$database;
3.2、備庫由snapshot standby 切換為 physical standby
idle>alter database convert to physical standby;
切換過程中跟蹤日誌
Sun Aug 24 01:26:09 2014 alter database convert to physical standby ALTER DATABASE CONVERT TO PHYSICAL STANDBY (SH) Flashback Restore Start Flashback Restore Complete Drop guaranteed restore point Stopping background process RVWR Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/DGDB/SHANGHAI/flashback/o1_mf_9zlxdhmc_.flb Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/DGDB/SHANGHAI/flashback/o1_mf_9zlxdl5k_.flb Guaranteed restore point dropped Clearing standby activation ID 2202357444 (0x83454ec4) The primary database controlfile was created using the 'MAXLOGFILES 16' clause. There is space for up to 13 standby redo logfiles Use the following SQL commands on the standby database to create standby redo logfiles that match the primary database: ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 52428800; ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 52428800; ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 52428800; ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 52428800; Shutting down archive processes Archiving is disabled Sun Aug 24 01:26:09 2014 ARCH shutting down ARC3: Archival stopped Sun Aug 24 01:26:09 2014 ARCH shutting down ARC2: Archival stopped Sun Aug 24 01:26:09 2014 ARCH shutting down ARC1: Archival stopped Sun Aug 24 01:26:09 2014 ARCH shutting down ARC0: Archival stopped Completed: alter database convert to physical standby |
切換完成後例項處於started狀態
sys@DGDB>select instance_name,status from v$instance;
3.3、重啟備庫到mount狀態,檢視當前備庫角色
sys@DGDB>startup mount force;
sys@DGDB>select database_role, open_mode, protection_mode, protection_level from v$database;
3.4、備庫開庫,檢視測試表
sys@DGDB>alter database open;
sys@DGDB>select database_role, open_mode, protection_mode, protection_level from v$database;
檢視測試表 條數不再是24條,而是恢復到切換前與主庫相同的10條
3.5、備庫上Real-time Apply 方式應用日誌
sys@DGDB>alter database recover managed standby database using current logfile disconnect;
【實驗總結】
1、切換Snapshot standby前,物理備庫需設定快速回復區db_recovery_file_dest。
2、物理備庫切換為Snapshot standby狀態前,需取消備庫的日誌應用。
3、物理備庫切換為Snapshot standby時,會建立一個restore point,當需要從snapshot standby狀態切回原來的狀態時,會回到這個restore point的狀態,期間在snapshot standby 的備庫上寫入的資料將不再存在。
呂星昊
2014.8.24
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29475508/viewspace-1256816/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 11g Dataguard中的snapshot standby特性
- 【DataGuard】Oracle 11g DataGuard 新特性之 Active Standby:Real-Time Apply+QueryOracleAPP
- 【DataGuard】Oracle 11g物理Data Guard之Snapshot Standby資料庫功能Oracle資料庫
- 使用oracle 11g rman新特性 duplicate target database for standby from active database 建立物理dataguard並開啟RealOracleDatabase
- 【轉】【DataGuard】Oracle 11g物理Data Guard之Snapshot Standby資料庫功能Oracle資料庫
- Oracle DataGuard Standby database ID mismatch錯誤OracleDatabase
- 11g新特性--active dataguard
- 【DataGuard】Oracle 11g physical standby switchoverOracle
- oracle 之dataguard standby 切換Oracle
- ORACLE10g DataGuard 配置Physical Standby DatabaseOracleDatabase
- 【DATAGUARD】Oracle19c dataguard新特性及部署Oracle
- 【DATAGUARD】 將11g物理備庫轉換為Snapshot Standby
- Oracle之11g DataGuardOracle
- 11g 新特性—— Active Database Duplication for A standby databaseDatabase
- oracle 11g中的snapshot standby特性Oracle
- 【DataGuard】11g 新特性:Active Data Guard
- Oracle 11.2.0.4 physical dataguard和snapshot dataguard切換Oracle
- 聊聊Oracle 11g的Snapshot Standby Database(上)OracleDatabase
- 聊聊Oracle 11g的Snapshot Standby Database(下)OracleDatabase
- 【DATAGUARD】DG系列之11g新特性簡單介紹
- Oracle 9I dataguard(standby)Oracle
- Oracle 11g Data Guard (physical standby - active dataguard) [final]Oracle
- oracle 11g dataguardOracle
- 11g rman新特性 duplicate target database for standby from active databaseDatabase
- ORACLE 11G DataGuard Failover後如何修復standby庫OracleAI
- Convert a Physical Standby Database into a Snapshot Standby DatabaseDatabase
- oracle 11G dataguard配置Oracle
- oracle 11g dataguard 建立Oracle
- Oracle 11g Active DataguardOracle
- DataGuard:Physical Standby Switchover
- 11g RMAN新特性 active database duplication createing standbyDatabase
- Physical Standby Database 切換到 Snapshot Standby DatabaseDatabase
- 探索ORACLE之11g DataGuard_01概念Oracle
- dataguard之物理standby 日誌切換
- Oracle11g的Dataguard測試,建立物理備庫(Physical Standby Database)OracleDatabase
- 【DATAGUARD】Data Guard 12C 新特性:Far Sync Standby (Doc ID 2179719.1)
- [zt] Oracle 11g DataGuard 配置Oracle
- 【DataGuard】手工冷備搭建 Oracle 11g DataGuard 物理備庫Oracle