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

#PDB級閃回(Flashback PDB)

#PDB閃回有幾個基本的前提條件:

1,enable local undo

2,enable archivelog mode

3,enable flashback database;

#停快速故障轉移功能

DGMGRL>?stop observer

DGMGRL>?disable fast_start failover;

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

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 級別創(chuàng)建 restore points:

連接到特定的 PDB 然后運行 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;? ?#正常還原點 (和如下2選1)

SQL> create restore point pdb1_10041344?guarantee flashback database;? #擔保還原點

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

SQL> alter session set container=CDB$ROOT;

#正常還原點 (和如下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;

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

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

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


#pdb

#CDB


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

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

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

#PDB

#CDB

##開始還原

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

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

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

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;

#備庫日誌如下:

#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

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

DGMGRL> show database 'DG125';

Database - DG125

? Role:? ? ? ? ? ? ? PRIMARY

? Intended State:? ? TRANSPORT-ON

? Instance(s):

? ? DG

Database Status:

SUCCESS

但是備庫存在錯誤

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';

#備庫

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;

#啟用備庫應用

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



#還原到還原點(restore point)?pdb1_10041344?

#主庫

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ù)未見回滾,但是PDB 數(shù)據(jù)回滾到 pdb1_10041344 點時刻

#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

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

DGMGRL> show database 'DG125';

Database - DG125

? Role:? ? ? ? ? ? ? PRIMARY

? Intended State:? ? TRANSPORT-ON

? Instance(s):

? ? DG

Database Status:

SUCCESS

但是備庫存在錯誤

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';

#備庫

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;

#啟用備庫應用

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

#啟動快速故障轉移功能

DGMGRL>?enable fast_start failover;

DGMGRL>?start observer

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

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,786評論 6 534
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 98,656評論 3 419
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 176,697評論 0 379
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,098評論 1 314
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,855評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 55,254評論 1 324
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,322評論 3 442
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,473評論 0 289
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 49,014評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,833評論 3 355
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,016評論 1 371
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,568評論 5 362
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 44,273評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,680評論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,946評論 1 288
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,730評論 3 393
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,006評論 2 374

推薦閱讀更多精彩內容