Oracle 21c support flashback database of PDB
本站文章除注明转载外,均为本站原创: 转载自love wife love life —Roger的Oracle/MySQL/PostgreSQL数据恢复博客
近几天Oracle 21c终于发布提供下载了,目前发布了x86版本,之前看文档说21c 支持PDB级别的flashback database闪回,这是一个不错的特性。这里进行测试验证一下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
SQL> alter session set container=tongtong; Session altered. SQL> create table enmotech as select * from sys.dba_objects; Table created. SQL> select count(1) from enmotech; COUNT(1) ---------- 75167 SQL> SQL> alter system checkpoint; System altered. SQL> select con_id,file#,checkpoint_change# from v$datafile_header where con_id=3; CON_ID FILE# CHECKPOINT_CHANGE# ---------- ---------- ------------------ 3 9 2657724 3 10 2657724 3 11 2657724 3 12 2657724 SQL> drop table enmotech purge; Table dropped. SQL> alter system checkpoint; System altered. SQL> select con_id,file#,checkpoint_change# from v$datafile_header where con_id=3; CON_ID FILE# CHECKPOINT_CHANGE# ---------- ---------- ------------------ 3 9 2658092 3 10 2658092 3 11 2658092 3 12 2658092 SQL> conn /as sysdba Connected. SQL> alter pluggable database tongtong close; Pluggable database altered. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 TONGTONG MOUNTED SQL> alter session set container=tongtong; Session altered. SQL> flashback pluggable database to scn 2657724; Flashback complete. SQL> alter pluggable database open resetlogs; Pluggable database altered. SQL> select count(1) from enmotech; COUNT(1) ---------- 75167 SQL> select * from v$Log; GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARCHIV STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME CON_ID ---------- ---------- ---------- ---------- ---------- ---------- ------ -------------------------------- ------------- ------------ ------------ ------------ ---------- 1 1 4 209715200 512 2 YES ACTIVE 2659112 21-AUG-21 2659121 21-AUG-21 0 2 1 5 209715200 512 2 YES ACTIVE 2659121 21-AUG-21 2659130 21-AUG-21 0 3 1 6 209715200 512 2 NO CURRENT 2659130 21-AUG-21 9.2954E+18 0 SQL> |
从上面来看,pdb级别的闪回操作方式跟之前差不多。flashback database操作,必须要以resetlogs方式打开;不过这里有一点需要注意的是,PDB级别的闪回并不会重置redo。因为多租户环境下,Redo是属于CDB级别,因此从技术层面来讲也不可能会被重置,否则cdb中的其他pdb就会存在数据丢失了。那么这个技术是如何实现的呢?目前还不清楚,抽空再深入研究一下。从alert log来看,也能获得一定信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
2021-08-21T12:49:46.738392+08:00 TONGTONG(3):alter pluggable database open resetlogs 2021-08-21T12:49:46.758082+08:00 Online datafile 12 Online datafile 11 Online datafile 10 Online datafile 9 TONGTONG(3):Pluggable database TONGTONG pseudo opening TONGTONG(3):SUPLOG: Initialize PDB SUPLOG SGA, old value 0x0, new value 0x18 TONGTONG(3):Autotune of undo retention is turned on. TONGTONG(3):Endian type of dictionary set to little TONGTONG(3):Undo initialization recovery: Parallel FPTR failed: start:430051647 end:430051650 diff:3 ms (0.0 seconds) TONGTONG(3):Undo initialization recovery: err:0 start: 430051647 end: 430051674 diff: 27 ms (0.0 seconds) TONGTONG(3):[25901] Successfully onlined Undo Tablespace 2. TONGTONG(3):Undo initialization online undo segments: err:0 start: 430051674 end: 430051684 diff: 10 ms (0.0 seconds) TONGTONG(3):Undo initialization finished serial:0 start:430051647 end:430051686 diff:39 ms (0.0 seconds) TONGTONG(3):Database Characterset for TONGTONG is AL32UTF8 TONGTONG(3):Pluggable database TONGTONG pseudo closing TONGTONG(3):JIT: pid 25901 requesting stop TONGTONG(3):Closing sequence subsystem (430051724518). TONGTONG(3):Buffer Cache flush started: 3 TONGTONG(3):Buffer Cache flush finished: 3 TONGTONG(3):Pluggable database TONGTONG opening in read write TONGTONG(3):SUPLOG: Initialize PDB SUPLOG SGA, old value 0x0, new value 0x18 TONGTONG(3):Autotune of undo retention is turned on. TONGTONG(3):Endian type of dictionary set to little TONGTONG(3):Undo initialization recovery: Parallel FPTR failed: start:430051946 end:430051948 diff:2 ms (0.0 seconds) TONGTONG(3):Undo initialization recovery: err:0 start: 430051945 end: 430051959 diff: 14 ms (0.0 seconds) TONGTONG(3):[25901] Successfully onlined Undo Tablespace 2. TONGTONG(3):Undo initialization online undo segments: err:0 start: 430051959 end: 430052050 diff: 91 ms (0.1 seconds) TONGTONG(3):Undo initialization finished serial:0 start:430051945 end:430052054 diff:109 ms (0.1 seconds) TONGTONG(3):Pluggable database TONGTONG dictionary check beginning TONGTONG(3):Pluggable Database TONGTONG Dictionary check complete TONGTONG(3):Database Characterset for TONGTONG is AL32UTF8 2021-08-21T12:49:47.877256+08:00 TONGTONG(3):SUPLOG: Set PDB SUPLOG SGA at PDB OPEN, old 0x18, new 0x0 (no suplog) TONGTONG(3):Opening pdb with no Resource Manager plan active Control autobackup written to DISK device handle '/data2/oracle21c/oradata/TEST/autobackup/2021_08_21/o1_mf_s_1081169388_jl11hdfk_.bkp' Pluggable database TONGTONG closed TONGTONG(3):Completed: alter pluggable database open resetlogs |
既然能够进行PDB级别的resetlogs操作,那么想必应该也可以进行PDB级别的跨resetlogs进行恢复了,即PDB也有incarnation的概念。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
SQL> SELECT con_id, status, pdb_incarnation# inc#, begin_resetlogs_scn, end_resetlogs_scn 2 FROM v$pdb_incarnation ORDER BY 3; CON_ID STATUS INC# BEGIN_RESETLOGS_SCN END_RESETLOGS_SCN ---------- -------------- ---------- ------------------- ----------------- 3 PARENT 0 2601843 2601843 3 CURRENT 1 2659186 2659186 RMAN> list incarnation of pluggable database tongtong; List of Pluggable Database Incarnations DB Key PDB Key PDBInc Key DBInc Key PDB Name Status Inc SCN Inc Time Begin Reset SCN Begin Reset Time ------- ------- -------- --------- ------- -------- --------------- ------------------ --------------- ------------------ 2 3 1 2 TONGTONG CURRENT 2657725 21-AUG-21 2659186 21-AUG-21 End Reset SCN:2659186 End Reset Time:21-AUG-21 Guid:CA0B301B61785F0AE053026CA8C00FD3 2 3 0 2 TONGTONG PARENT 2601843 21-AUG-21 2601843 21-AUG-21 End Reset SCN:2601843 End Reset Time:21-AUG-21 Guid:CA0B301B61785F0AE053026CA8C00FD3 RMAN> [oracle@mysqldb1 ~]$ sqlplus "/as sysdba" SQL*Plus: Release 21.0.0.0.0 - Production on Sat Aug 21 13:06:09 2021 Version 21.3.0.0.0 Copyright (c) 1982, 2021, Oracle. All rights reserved. Connected to: Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production Version 21.3.0.0.0 SQL> alter session set container=tongtong; Session altered. SQL> alter pluggable database tongtong close; Pluggable database altered. SQL> flashback pluggable database to scn 2657723; Flashback complete. SQL> alter pluggable database open resetlogs; Pluggable database altered. SQL> SQL> exit Disconnected from Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production Version 21.3.0.0.0 [oracle@mysqldb1 ~]$ rman target / Recovery Manager: Release 21.0.0.0.0 - Production on Sat Aug 21 13:07:29 2021 Version 21.3.0.0.0 Copyright (c) 1982, 2021, Oracle and/or its affiliates. All rights reserved. connected to target database: TEST (DBID=2379313654) RMAN> list incarnation of pluggable database tongtong; using target database control file instead of recovery catalog List of Pluggable Database Incarnations DB Key PDB Key PDBInc Key DBInc Key PDB Name Status Inc SCN Inc Time Begin Reset SCN Begin Reset Time ------- ------- -------- --------- ------- -------- --------------- ------------------ --------------- ------------------ 2 3 2 2 TONGTONG CURRENT 2657724 21-AUG-21 2663183 21-AUG-21 End Reset SCN:2663183 End Reset Time:21-AUG-21 Guid:CA0B301B61785F0AE053026CA8C00FD3 2 3 1 2 TONGTONG ORPHAN 2657725 21-AUG-21 2659186 21-AUG-21 End Reset SCN:2659186 End Reset Time:21-AUG-21 Guid:CA0B301B61785F0AE053026CA8C00FD3 2 3 0 2 TONGTONG PARENT 2601843 21-AUG-21 2601843 21-AUG-21 End Reset SCN:2601843 End Reset Time:21-AUG-21 Guid:CA0B301B61785F0AE053026CA8C00FD3 RMAN> |
从测试来看如我们所料。果然是支持的。可以看到Oracle 21c的功能越来越强大了。国产数据库的追赶路途,又要被拉大了。。。
Leave a Reply
You must be logged in to post a comment.