ORACLE 12C ADG 之十四 (ADG PDB級(jí)閃回(Flashback PDB))

#PDB級(jí)閃回(Flashback PDB)

#PDB閃回有幾個(gè)基本的前提條件:

1,enable local undo

2,enable archivelog mode

3,enable flashback database;

#停快速故障轉(zhuǎn)移功能

DGMGRL>?stop observer

DGMGRL>?disable fast_start failover;

#主庫(kù)停止日志傳到從庫(kù)(可選操作)

SQL>alter system set log_archive_dest_state_2=defer scope=both;? (可選擇)


[oracle@XAG126 ~]$ dgmgrl sys/123456

Connected to "DG126"

Connected as SYSDG.

DGMGRL> show configuration;

Configuration - ADGbroker

? Protection Mode: MaxAvailability

? Members:

? DG125 - Primary database

? ? DG126 - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS? (status updated 3 seconds ago)

[oracle@XAG125 ~]$ sqlplus / as sysdba

SQL> select database_role,flashback_on from v$database;

????????????PRIMARY YES

SQL> show parameter db_recovery_file_dest

db_recovery_file_dest ? ? string /u01/app/oracle/fast_recovery_area/ORACLE12CDG

db_recovery_file_dest_size ? ? big integer 8016M

SQL> show parameter flashback

db_flashback_retention_target ? ? integer 1440

SQL>?select flashback_on from v$database;

????????????YES

SQL> show pdbs

2 PDB$SEED ? READ ONLY? NO

3 PDB1 ? READ WRITE NO

1. 在 PDB 級(jí)別創(chuàng)建 restore points:

連接到特定的 PDB 然后運(yùn)行 CREATE RESTORE POINT 命令:

SQL> alter session set container=PDB1;

SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi') from dual;

????????????2018-10-04 13:44

SQL> create restore point pdb1_10041344;? ?#正常還原點(diǎn) (和如下2選1)

SQL> create restore point pdb1_10041344?guarantee flashback database;? #擔(dān)保還原點(diǎn)

連接到 CDB,并使用 CREATE RESTORE POINT 命令的 FOR PLUGGABLE DATABASE 子句:

SQL> alter session set container=CDB$ROOT;

#正常還原點(diǎn) (和如下2選1)

SQL> create restore point pdb1_10041344?for pluggable database PDB1;?

SQL> create restore point pdb1_10041344?for pluggable database PDB1 guarantee flashback database;

#第一次測(cè)試輸入插入 CDB 及 PDB 都插入測(cè)試數(shù)據(jù)

SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi') from dual;

? ??????????2018-10-04 13:45


#pdb

#CDB


#第二次測(cè)試輸入插入 CDB 及 PDB 都插入測(cè)試數(shù)據(jù)

SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi') from dual;

????????????2018-10-04 13:50

#PDB

#CDB

##開(kāi)始還原

#還原到第一次(13:45)插入后,第二次(13:50)插入前時(shí)間 即13:47

flashback backup在12.2中有rman和SQL兩種方式閃回, 當(dāng)使用shared undo里需要使用rman,前提需要在pdb close immediate后創(chuàng)建clean resotre point, 過(guò)程中會(huì)自動(dòng)創(chuàng)建輔助實(shí)例CDB和PDB PITR;?

使用local undo時(shí),就可以使用SQL命令更佳快速,而且只是pdb 數(shù)據(jù)文件原位置閃回,并應(yīng)用undo,在做之前創(chuàng)建任意一種restore point都可以,也不需要輔助實(shí)例。

SQL> show pdbs;

????????????3 PDB1 ? READ WRITE NO

SQL> shutdown immediate;? or?alter pluggable database PDB1 close;

SQL> show pdbs;

????????????3 PDB1 ? MOUNTED

SQL> FLASHBACK PLUGGABLE DATABASE PDB1 TO TIMESTAMP to_timestamp('2018-10-04 13:47:00','yyyy-mm-dd hh24:mi:ss');

SQL> alter pluggable database PDB1? open resetlogs;

#備庫(kù)日誌如下:

#ADG 狀態(tài)如下

DGMGRL> show configuration;

Configuration - ADGbroker

? Protection Mode: MaxAvailability

? Members:

? DG125 - Primary database

? ? DG126 - Physical standby database

? ? ? Error: ORA-16810: multiple errors or warnings detected for the member

Fast-Start Failover: DISABLED

Configuration Status:

ERROR? (status updated 37 seconds ago)

DGMGRL> show database 'DG126' statusreport

STATUS REPORT

? ? ? INSTANCE_NAME? SEVERITY ERROR_TEXT

? ? ? ? ? ? ? ? ? *? ? WARNING ORA-16853: apply lag has exceeded specified threshold

? ? ? ? ? ? ? ? ? *? ? ? ERROR ORA-16766: Redo Apply is stopped

#主庫(kù)狀態(tài)如下

DGMGRL> show database 'DG125';

Database - DG125

? Role:? ? ? ? ? ? ? PRIMARY

? Intended State:? ? TRANSPORT-ON

? Instance(s):

? ? DG

Database Status:

SUCCESS

但是備庫(kù)存在錯(cuò)誤

DGMGRL> show database 'DG126';

Database - DG126

? Role:? ? ? ? ? ? ? PHYSICAL STANDBY

? Intended State:? ? APPLY-ON

? Transport Lag:? ? ? 0 seconds (computed 0 seconds ago)

? Apply Lag:? ? ? ? ? 7 minutes 28 seconds (computed 0 seconds ago)

? Average Apply Rate: 5.00 KByte/s

? Real Time Query:? ? OFF

? Instance(s):

? ? DG

? Database Error(s):

? ? ORA-16766: Redo Apply is stopped

? Database Warning(s):

? ? ORA-16853: apply lag has exceeded specified threshold

Database Status:

ERROR

?#alert log of the standby dataset we can find following errors

---------------------------------------------------------------------

2018-10-04T13:59:55.300500+08:00

(3):Recovery of pluggable database PDB1 aborted due to pluggable database open resetlog marker.

(3):To continue recovery, restore all data files for this PDB to checkpoint SCN lower than 2820243, or timestamp before 10/04/2018 13:47:02, and restart recovery

MRP0: Background Media Recovery terminated with error 39874

2018-10-04T13:59:55.301469+08:00

Errors in file /u01/app/oracle/diag/rdbms/dg126/DG/trace/DG_pr00_1448.trc:

ORA-39874: Pluggable Database PDB1 recovery halted

ORA-39873: Restore all data files to a checkpoint SCN lower than 2820243.

Managed Standby Recovery not using Real Time Apply

Recovery interrupted!

Recovered data files to a consistent state at change 2822396

2018-10-04T13:59:55.425604+08:00

Errors in file /u01/app/oracle/diag/rdbms/dg126/DG/trace/DG_pr00_1448.trc:

ORA-39874: Pluggable Database PDB1 recovery halted

ORA-39873: Restore all data files to a checkpoint SCN lower than 2820243.

2018-10-04T13:59:55.526502+08:00

MRP0: Background Media Recovery process shutdown (DG)

---------------------------------------------------------------------------------------------

On the primary PDB, we can can query the current INCARNATION_SCN in the v$pdb_incarnation view. And we can remark that the current SCN is the same that the one specified in the standby alert log?2820243

SQL> show con_name

CON_NAME

------------------------------

PDB1

SQL> select status,INCARNATION_SCN from v$pdb_incarnation;

STATUS ? ? ? INCARNATION_SCN

--------------------- ---------------

CURRENT ? ? ? 2820243

PARENT ? ? ? 2756861

PARENT ? ? ? 2756236

PARENT ? ? ? 2741913

PARENT ? ? ? 2741034

PARENT ? ? ? 1408558

#And then as specified in the alert log we have to flashback the standby pdb to a SCN lower than 2820243

First let’s stop the redo apply on the standby

DGMGRL> edit database 'DG126' set state='APPLY-OFF';

#備庫(kù)

And then let’s flashback to 2820241( i.e 2820243-2 ) for example

Let’s shutdown the standby container and startup it in a mount state

SQL> select name,open_mode from v$pdbs;

PDB$SEED????????????????READ ONLY

PDB1????????????????????????????READ ONLY

PDB8????????????????????????????READ ONLY

SQL> show pdbs

2 PDB$SEED ? READ ONLY? NO

3 PDB1 ? READ ONLY? NO

4 PDB8 ? READ ONLY? NO

SQL> shutdown immediate;

SQL> startup mount;

SQL>?flashback pluggable database PDB1 to SCN 2820241;

#啟用備庫(kù)應(yīng)用

DGMGRL> edit database 'DG126' set state='APPLY-ON';

#檢查ADG狀態(tài)

DGMGRL> show configuration

Configuration - ADGbroker

? Protection Mode: MaxAvailability

? Members:

? DG125 - Primary database

? ? DG126 - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS? (status updated 4 seconds ago)

#OPEN DB

SQL> alter database open;

Database altered.

SQL> show pdbs;

? ? CON_ID CON_NAME ? OPEN MODE? RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED ? READ ONLY? NO

3 PDB1 ? READ ONLY? NO

4 PDB8 ? READ ONLY? NO



#還原到還原點(diǎn)(restore point)?pdb1_10041344?

#主庫(kù)

SQL> show pdbs;

????????????3 PDB1 ? READ WRITE NO

SQL> shutdown immediate; or alter pluggable database PDB1 close;

SQL> show pdbs;

????????????3 PDB1 ? MOUNTED

SQL> FLASHBACK PLUGGABLE DATABASE PDB1?TO RESTORE POINT pdb1_10041344;

SQL> alter pluggable database PDB1 open resetlogs;

#檢查CDB數(shù)據(jù)未見(jiàn)回滾,但是PDB 數(shù)據(jù)回滾到 pdb1_10041344 點(diǎn)時(shí)刻

#ADG 狀態(tài)如下

DGMGRL> show configuration;

Configuration - ADGbroker

? Protection Mode: MaxAvailability

? Members:

? DG125 - Primary database

? ? DG126 - Physical standby database

? ? ? Error: ORA-16810: multiple errors or warnings detected for the member

Fast-Start Failover: DISABLED

Configuration Status:

ERROR? (status updated 37 seconds ago)

DGMGRL> show database 'DG126' statusreport

STATUS REPORT

? ? ? INSTANCE_NAME? SEVERITY ERROR_TEXT

? ? ? ? ? ? ? ? ? *? ? WARNING ORA-16853: apply lag has exceeded specified threshold

? ? ? ? ? ? ? ? ? *? ? ? ERROR ORA-16766: Redo Apply is stopped

#主庫(kù)狀態(tài)如下

DGMGRL> show database 'DG125';

Database - DG125

? Role:? ? ? ? ? ? ? PRIMARY

? Intended State:? ? TRANSPORT-ON

? Instance(s):

? ? DG

Database Status:

SUCCESS

但是備庫(kù)存在錯(cuò)誤

DGMGRL> show database 'DG126';

Database - DG126

? Role:? ? ? ? ? ? ? PHYSICAL STANDBY

? Intended State:? ? APPLY-ON

? Transport Lag:? ? ? 0 seconds (computed 0 seconds ago)

? Apply Lag:? ? ? ? ? 7 minutes 28 seconds (computed 0 seconds ago)

? Average Apply Rate: 5.00 KByte/s

? Real Time Query:? ? OFF

? Instance(s):

? ? DG

? Database Error(s):

? ? ORA-16766: Redo Apply is stopped

? Database Warning(s):

? ? ORA-16853: apply lag has exceeded specified threshold

Database Status:

ERROR

#alert log of the standby dataset we can find following errors

---------------------------------------------------------------------

2018-10-04T14:34:03.978752+08:00

Errors in file /u01/app/oracle/diag/rdbms/dg126/DG/trace/DG_pr00_2701.trc:

ORA-39874: Pluggable Database PDB1 recovery halted

ORA-39873: Restore all data files to a checkpoint SCN lower than 2820013.

Managed Standby Recovery not using Real Time Apply

Recovery interrupted!

Recovered data files to a consistent state at change 2828721

2018-10-04T14:34:04.096906+08:00

Errors in file /u01/app/oracle/diag/rdbms/dg126/DG/trace/DG_pr00_2701.trc:

ORA-39874: Pluggable Database PDB1 recovery halted

ORA-39873: Restore all data files to a checkpoint SCN lower than 2820013.

2018-10-04T14:34:04.197542+08:00

MRP0: Background Media Recovery process shutdown (DG)

#On the primary PDB, we can can query the current INCARNATION_SCN in the v$pdb_incarnation view. And we can remark that the current SCN is the same that the one specified in the standby alert log 2820013

SQL> show con_name

CON_NAME

------------------------------

PDB1

SQL> select status,INCARNATION_SCN from v$pdb_incarnation;

STATUS ? ? ? INCARNATION_SCN

--------------------- ---------------

CURRENT ? ? ? 2820013

PARENT ? ? ? 2756861

PARENT ? ? ? 2756236

PARENT ? ? ? 2741913

PARENT ? ? ? 2741034

PARENT ? ? ? 1408558

ORPHAN ? ? ? 2820243

7 rows selected.

#And then as specified in the alert log we have to flashback the standby pdb to a SCN lower than 2820013

First let’s stop the redo apply on the standby

DGMGRL> edit database 'DG126' set state='APPLY-OFF';

#備庫(kù)

And then let’s flashback to 2820011( i.e 2820013-2 ) for example

Let’s shutdown the standby container and startup it in a mount state

SQL> show pdbs

2 PDB$SEED ? READ ONLY? NO

3 PDB1? READ ONLY? NO

4 PDB8? READ ONLY? NO

SQL> shutdown immediate;

SQL> startup mount;

SQL> flashback pluggable database PDB1 to SCN 2820011;

#啟用備庫(kù)應(yīng)用

DGMGRL> edit database 'DG126' set state='APPLY-ON';

#檢查ADG狀態(tài)

DGMGRL> show configuration

Configuration - ADGbroker

? Protection Mode: MaxAvailability

? Members:

? DG125 - Primary database

? ? DG126 - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS? (status updated 4 seconds ago)

#OPEN DB

SQL> alter database open;

Database altered.

SQL> show pdbs;

? ? CON_ID CON_NAME ? OPEN MODE? RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED ? READ ONLY? NO

3 PDB1? READ ONLY? NO

4 PDB8? READ ONLY? NO

#啟動(dòng)快速故障轉(zhuǎn)移功能

DGMGRL>?enable fast_start failover;

DGMGRL>?start observer

參考?http://blog.dbi-services.com/oracle-12-2-dataguard-pdb-flashback-on-the-primary/

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容