關於 RMAN 對於可插拔資料庫按時間點的恢復 (文件 ID 1984554.1)

mosdoc發表於2016-12-14

文件內容


用途

適用範圍

詳細資訊

參考


適用於:

Oracle Database - Enterprise Edition - 版本 12.1.0.1 和更高版本
本文件所含資訊適用於所有平臺

用途

關於如何使用 RMAN 對可插拔資料庫按時間點恢復的概述 - oracle 12C 新功能。

適用範圍

本文件適用於 DBA 使用 RMAN 模式備份大規模資料庫(CDB 包含一個或多個 PDB)。

要求瞭解 RMAN 知識和 RMAN 架構。
要求先檢視下面的 Note:RMAN Pluggable Database Backup and Recovery (Note 1521005.1)

詳細資訊

關於可插拔資料庫(指的是 PDB)的時間點恢復,需要包括 undo 在內的所有檔案被恢復並且恢復至指定的時間點。由於所有的 PDB 資料庫均寫到根節點的 UNDO 表空間,所以 PDB 資料庫的時間點恢復需要使用輔助例項(auxiliary)並且將 CDB$ROOT UNDO,SYSTEM,SYSAUX 和 SYSEXT 表空間恢復至輔助例項的根節點。 PDB 資料庫自身的資料檔案則恢復至其原有位置。

如果配置了快速恢復區,則輔助例項被建立在快速恢復區(fast recovery area),否則透過 AUXILIARY DESTINATION 引數指定到其它位置。

透過 RMAN 來完成恢復,需連線到跟容器(root container)。
PDB 資料庫必須在關閉狀態下恢復,但根及其它 PDB 資料庫可以是開啟狀態。

 SQL> select con.name, df.file#
      from v$containers con, v$datafile df
      where con.con_id = df.con_id
      order by 1, 2;

NAME                                FILE#
------------------------------ ----------
CDB$ROOT                                1
CDB$ROOT                                3
CDB$ROOT                                4
CDB$ROOT                                6
PDB$SEED                                5
PDB$SEED                                7
PDBC101                                 8
PDBC101                                 9
PDBC101                                10

9 rows selected.


 
下面就是一個使用 AUXILIARY DESTINATION 引數替代預設快速恢復區的例子。

Recovery Manager: Release 12.1.0.1.0 - Production on Tue Jul 2 12:05:51 2013

Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

connected to target database: CDBC101 (DBID=958900840)

RMAN> ALTER PLUGGABLE DATABASE pdbc101 CLOSE;
2> run
3> {
4>    SET UNTIL sequence 21 thread 1;
5>    RESTORE PLUGGABLE DATABASE pdbc101;
6>    RECOVER PLUGGABLE DATABASE pdbc101
7>       AUXILIARY DESTINATION '/u02/nfs_share/ora_data';
8> }
9> ALTER PLUGGABLE DATABASE pdbc101 OPEN RESETLOGS;
10>
11>
using target database control file instead of recovery catalog
Statement processed

executing command: SET until clause

Starting restore at 02-JUL-2013 12:05:56                <--- This is the restore of the PDB datafiles
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00008 to /u02/nfs_share/ora_data/CDBC101/E0749F57C768731AE043A1DCA10A2DCA/datafile/o1_mf_system_8x32r2sh_.dbf
channel ORA_DISK_1: restoring datafile 00009 to /u02/nfs_share/ora_data/CDBC101/E0749F57C768731AE043A1DCA10A2DCA/datafile/o1_mf_sysaux_8x32r2o7_.dbf
channel ORA_DISK_1: restoring datafile 00010 to /u02/nfs_share/ora_data/CDBC101/E0749F57C768731AE043A1DCA10A2DCA/datafile/o1_mf_users_8x32szkj_.dbf
channel ORA_DISK_1: reading from backup piece /u02/nfs_share/reco_area/CDBC101/E0749F57C768731AE043A1DCA10A2DCA/backupset/2013_07_01/o1_mf_nnndf_TAG20130701T175102_8x39fwqb_.bkp
channel ORA_DISK_1: piece handle=/u02/nfs_share/reco_area/CDBC101/E0749F57C768731AE043A1DCA10A2DCA/backupset/2013_07_01/o1_mf_nnndf_TAG20130701T175102_8x39fwqb_.bkp tag=TAG20130701T175102
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:46
Finished restore at 02-JUL-2013 12:06:42

Starting recover at 02-JUL-2013 12:06:42
using channel ORA_DISK_1
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time

List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1

Creating automatic instance, with SID='sDdj'

initialization parameters used for automatic instance:
db_name=CDBC101
db_unique_name=sDdj_pitr_pdbc101_CDBC101
compatible=12.1.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
diagnostic_dest=/u01/app/oracle
db_create_file_dest=/u02/nfs_share/ora_data
log_archive_dest_1='location=/u02/nfs_share/ora_data'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used


starting up automatic instance CDBC101                             <---- Starting another instance (besides the current running original database).

Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2296576 bytes
Variable Size                293602560 bytes
Database Buffers             767557632 bytes
Redo Buffers                   5480448 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set until  logseq 21 thread 1;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
}
executing Memory Script

executing command: SET until clause

Starting restore at 02-JUL-2013 12:06:57
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=111 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u02/nfs_share/reco_area/CDBC101/autobackup/2013_07_01/o1_mf_s_819654840_8x39jtc8_.bkp
channel ORA_AUX_DISK_1: piece handle=/u02/nfs_share/reco_area/CDBC101/autobackup/2013_07_01/o1_mf_s_819654840_8x39jtc8_.bkp tag=TAG20130701T175400
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
output file name=/u02/nfs_share/ora_data/CDBC101/controlfile/o1_mf_8x59l3sl_.ctl
Finished restore at 02-JUL-2013 12:07:05

sql statement: alter database mount clone database

contents of Memory Script:
{
# set requested point in time
set until  logseq 21 thread 1;
# switch to valid datafilecopies
switch clone datafile  8 to datafilecopy  "/u02/nfs_share/ora_data/CDBC101/E0749F57C768731AE043A1DCA10A2DCA/datafile/o1_mf_system_8x32r2sh_.dbf";
switch clone datafile  9 to datafilecopy  "/u02/nfs_share/ora_data/CDBC101/E0749F57C768731AE043A1DCA10A2DCA/datafile/o1_mf_sysaux_8x32r2o7_.dbf";
switch clone datafile  10 to datafilecopy  "/u02/nfs_share/ora_data/CDBC101/E0749F57C768731AE043A1DCA10A2DCA/datafile/o1_mf_users_8x32szkj_.dbf";
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile  1 to new;
set newname for clone datafile  4 to new;
set newname for clone datafile  3 to new;
set newname for clone datafile  6 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  1, 4, 3, 6;
switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

datafile 8 switched to datafile copy
input datafile copy RECID=3 STAMP=819720431 file name=/u02/nfs_share/ora_data/CDBC101/E0749F57C768731AE043A1DCA10A2DCA/datafile/o1_mf_system_8x32r2sh_.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=4 STAMP=819720431 file name=/u02/nfs_share/ora_data/CDBC101/E0749F57C768731AE043A1DCA10A2DCA/datafile/o1_mf_sysaux_8x32r2o7_.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=5 STAMP=819720431 file name=/u02/nfs_share/ora_data/CDBC101/E0749F57C768731AE043A1DCA10A2DCA/datafile/o1_mf_users_8x32szkj_.dbf

executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME

Starting restore at 02-JUL-2013 12:07:11                     <---- This is the restore of the Root Container Database
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u02/nfs_share/ora_data/CDBC101/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u02/nfs_share/ora_data/CDBC101/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u02/nfs_share/ora_data/CDBC101/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u02/nfs_share/ora_data/CDBC101/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/nfs_share/reco_area/CDBC101/backupset/2013_07_01/o1_mf_nnndf_TAG20130701T175102_8x39c78w_.bkp
channel ORA_AUX_DISK_1: piece handle=/u02/nfs_share/reco_area/CDBC101/backupset/2013_07_01/o1_mf_nnndf_TAG20130701T175102_8x39c78w_.bkp tag=TAG20130701T175102
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:15
Finished restore at 02-JUL-2013 12:08:27

datafile 1 switched to datafile copy
input datafile copy RECID=10 STAMP=819720507 file name=/u02/nfs_share/ora_data/CDBC101/datafile/o1_mf_system_8x59ljbm_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=11 STAMP=819720507 file name=/u02/nfs_share/ora_data/CDBC101/datafile/o1_mf_undotbs1_8x59ljgm_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=12 STAMP=819720507 file name=/u02/nfs_share/ora_data/CDBC101/datafile/o1_mf_sysaux_8x59ljf6_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=13 STAMP=819720507 file name=/u02/nfs_share/ora_data/CDBC101/datafile/o1_mf_users_8x59ljjy_.dbf

contents of Memory Script:
{
# set requested point in time
set until  logseq 21 thread 1;
# online the datafiles restored or switched
sql clone "alter database datafile  1 online";
sql clone "alter database datafile  4 online";
sql clone "alter database datafile  3 online";
sql clone 'PDBC101' "alter database datafile 8 online";
sql clone 'PDBC101' "alter database datafile 9 online";
sql clone 'PDBC101' "alter database datafile 10 online";
sql clone "alter database datafile  6 online";
# recover pdb
recover clone database tablespace  "SYSTEM", "UNDOTBS1", "SYSAUX", "USERS" pluggable database
 'PDBC101'   delete archivelog;
sql clone 'alter database open read only';
plsql <<<begin
   add_dropped_ts;
end; >>>;
plsql <<<begin
   save_pdb_clean_scn;
end; >>>;
# shutdown clone before import
shutdown clone abort
plsql <<<begin
   pdbpitr_inspect(pdbname =>  'PDBC101');
end; >>>;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  1 online
sql statement: alter database datafile  4 online
sql statement: alter database datafile  3 online
sql statement: alter database datafile  8 online
sql statement: alter database datafile  9 online
sql statement: alter database datafile  10 online
sql statement: alter database datafile  6 online

Starting recover at 02-JUL-2013 12:08:28
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 16 is already on disk as file /u02/nfs_share/reco_area/CDBC101/archivelog/2013_07_01/o1_mf_1_16_8x39jq8g_.arc
archived log for thread 1 with sequence 17 is already on disk as file /u02/nfs_share/reco_area/CDBC101/archivelog/2013_07_01/o1_mf_1_17_8x3r1zf6_.arc
archived log for thread 1 with sequence 18 is already on disk as file /u02/nfs_share/reco_area/CDBC101/archivelog/2013_07_01/o1_mf_1_18_8x3r6pqc_.arc
archived log for thread 1 with sequence 19 is already on disk as file /u02/nfs_share/reco_area/CDBC101/archivelog/2013_07_01/o1_mf_1_19_8x3rcrrv_.arc
archived log for thread 1 with sequence 20 is already on disk as file /u02/nfs_share/reco_area/CDBC101/archivelog/2013_07_02/o1_mf_1_20_8x4620tk_.arc
archived log file name=/u02/nfs_share/reco_area/CDBC101/archivelog/2013_07_01/o1_mf_1_16_8x39jq8g_.arc thread=1 sequence=16
archived log file name=/u02/nfs_share/reco_area/CDBC101/archivelog/2013_07_01/o1_mf_1_17_8x3r1zf6_.arc thread=1 sequence=17
archived log file name=/u02/nfs_share/reco_area/CDBC101/archivelog/2013_07_01/o1_mf_1_18_8x3r6pqc_.arc thread=1 sequence=18
archived log file name=/u02/nfs_share/reco_area/CDBC101/archivelog/2013_07_01/o1_mf_1_19_8x3rcrrv_.arc thread=1 sequence=19
archived log file name=/u02/nfs_share/reco_area/CDBC101/archivelog/2013_07_02/o1_mf_1_20_8x4620tk_.arc thread=1 sequence=20
media recovery complete, elapsed time: 00:00:21
Finished recover at 02-JUL-2013 12:08:52

sql statement: alter database open read only


Oracle instance shut down


Removing automatic instance
Automatic instance removed
auxiliary instance file /u02/nfs_share/ora_data/CDBC101/datafile/o1_mf_sysaux_8x59ljf6_.dbf deleted
auxiliary instance file /u02/nfs_share/ora_data/CDBC101/controlfile/o1_mf_8x59l3sl_.ctl deleted
Finished recover at 02-JUL-2013 12:09:02

Statement processed

Recovery Manager complete.

 

如果您想更多的控制輔助庫的配置,則您可以使用輔助引數檔案。

下面列出了需要包含的主要引數:

db_name=CDBC101                              <--- 與原始 CDB 相同名字
db_unique_name=sDdj_pitr_pdbc101_CDBC101     <--- 唯一名字,在這個主機必須唯一。
compatible=12.1.0.0.0                        <--- 與原始 CDB 相同名字
db_block_size=8192                           <--- 與原始 CDB 相同名字
db_files=200                                 <--- 與原始 CD B相同或者更高的值
sga_target=1G                                <--- 可配置
processes=80                                 <--- 確保足夠大,如果使用 ASM,還需要額外的程式
diagnostic_dest=/u01/app/oracle              <--- 可配置
enable_pluggable_database=true               <--- 強制!!
_clone_one_pdb_recovery=true                 <--- 強制!!

 

相關的命令如下:

RMAN>  ALTER PLUGGABLE DATABASE pdbc101 CLOSE;
run
{
   SET AUXILIARY INSTANCE PARAMETER FILE TO '/tmp/auxpfile.ora';

   SET UNTIL sequence 21 thread 1;
   RESTORE PLUGGABLE DATABASE pdbc101;
   RECOVER PLUGGABLE DATABASE pdbc101
      AUXILIARY DESTINATION '/u02/nfs_share/ora_data';
}
ALTER PLUGGABLE DATABASE pdbc101 OPEN RESETLOGS;

參考

NOTE:1521005.1 - RMAN Pluggable Database Backup and Recovery in a Multitenant Environment

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

相關文章