11R2-DataGuard Scenarios.主備庫的閃回

oracle_mao發表於2014-01-11


前言:在11R2中的DG中有8種場景,Using Flashback Database After Issuing an Open Resetlogs Statement是第三個場景,大體為在某種操作完成後,主庫可閃回之前的某一時間點,而備庫也可同樣閃回。
13.3 Using Flashback Database After Issuing an Open Resetlogs Statement
前言:由於某種需求,需要將主庫和備庫都閃回之前的某一個時間點,閃回後,資料庫需要open resetlogs開啟,而此時,備庫也需要閃回,否則就得重新搭建DG。
13.3.1 Flashing Back a Physical Standby Database to a Specific Point-in-Time
實驗環境:
 主庫+物理備庫。開啟主備庫閃回,隨後將主備庫都閃回到某一時間點(主庫:dong_pri  物理備庫:mm_stb)
step 0:開啟主備庫閃回
step 1:閃回主庫
主庫:
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
    1596972
SQL> alter system switch logfile;
System altered.
SQL> create table t_after as select * from dba_objects;
Table created.
SQL> alter system switch logfile;
System altered.
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
    1597219
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/diag/rdbms/dong/
Oldest online log sequence     107
Next log sequence to archive   109
Current log sequence           109
物理備庫:
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/diag/rdbms/dong/
Oldest online log sequence     107
Next log sequence to archive   0
Current log sequence           109
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
    1597214
開始閃回主庫:
SQL> shutdown immediate
SQL> startup mount
SQL> FLASHBACK STANDBY DATABASE TO SCN 1596972;
Flashback complete.
SQL> alter database open resetlogs;
Database altered.
SQL> select count(*) from t_after;
select count(*) from t_after
                     *
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/diag/rdbms/dong/
Oldest online log sequence     1
Next log sequence to archive   1
Current log sequence           3
SQL>  select current_scn from v$database;
CURRENT_SCN
-----------
    1597135
step 2:閃回物理備庫
SQL> shutdown immediate
SQL> startup mount
SQL> flashback database to scn 1594248;
Flashback complete.
step 3:測試
主庫:
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/diag/rdbms/dong/
Oldest online log sequence     2
Next log sequence to archive   4
Current log sequence           4
SQL> alter system switch logfile;
System altered.
物理備庫:
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/diag/rdbms/dong/
Oldest online log sequence     3
Next log sequence to archive   0
Current log sequence           107
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/diag/rdbms/dong/
Oldest online log sequence     3
Next log sequence to archive   0
Current log sequence           5
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  USING CURRENT LOGFILE DISCONNECT;

Database altered.

13.3.2 Flashing Back a Logical Standby Database to a Specific Point-in-Time
實驗環境:
 主庫+邏輯備庫。開啟主備庫閃回,隨後將主備庫都閃回到某一時間點(主庫:dong_pri  物理備庫:mm_stb2)。對於邏輯備庫閃回和物理備庫閃回其實沒啥區別。主要注意步驟不太相同即可。
step 0:開啟主備庫閃回
step 1:閃回主庫
 步驟與上一個實驗一樣。
step 2:閃回備庫
SQL> create table logical_after as select * from dba_objects;
Table created.
SQL> shutdown immediate
SQL> startup mount
SQL> FLASHBACK DATABASE TO SCN 1613195;
Flashback complete.
SQL> alter database open resetlogs;
SQL> SELECT resetlogs_id FROM V$DATABASE_INCARNATION WHERE status = 'CURRENT';
RESETLOGS_ID
------------
   836147774
SQL> SELECT * FROM DBA_LOGSTDBY_LOG WHERE resetlogs_id = 836147774;
no rows selected
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;
Database altered.

 

 

 

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24500180/viewspace-1069602/,如需轉載,請註明出處,否則將追究法律責任。

相關文章