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 级别创建 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 都插入测试数据

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

            2018-10-04 13:45


#pdb

#CDB


#第二次测试输入插入 CDB 及 PDB 都插入测试数据

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后创建clean resotre point, 过程中会自动创建辅助实例CDB和PDB PITR; 

使用local undo时,就可以使用SQL命令更佳快速,而且只是pdb 数据文件原位置闪回,并应用undo,在做之前创建任意一种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 狀態如下

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

#主庫狀態如下

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狀態

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

#ADG 狀態如下

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

#主庫狀態如下

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狀態

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/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,937评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,503评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,712评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,668评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,677评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,601评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,975评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,637评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,881评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,621评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,710评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,387评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,971评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,947评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,189评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,805评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,449评论 2 342

推荐阅读更多精彩内容