TSPITR 注意事项:
19C DBV expdp 不用exp imp
“TEST” 一定要“” 起来,否则说找不到test tablespace.
RAC中 thread 要指定对,否则过度恢复。
SEQUENCE# 是drop 时的,不是创建时的。
tablespace 默认是offline的,要online, 10G不知道是不是自动的!!
只能恢复一次。回复完后tablespace之前的备份不可用。
-----
-----------------Automatic TSPITR in 10G RMAN -A walk Through (Doc ID 335851.1)
For the purposes of this document, the following fictitious environment is used as an example to describe the procedure:
Database Name: PROD
Tablespace Name: TEST
Table Name: TEST001
Directory Location: D:\BACKUP\
SCOPE
RMAN automatic Tablespace Point-In-Time Recovery (TSPITR) enables you to quickly recover one or more tablespaces in an Oracle database to an earlier time, without affecting the state of the rest of the tablespaces and other objects in the database.
DETAILS
When performing fully automated TSPITR, letting RMAN manage the entire process. There are only two requirements which we need to specify manually.
1. Auxiliary destination for RMAN to use for the auxiliary set datafiles and other files for the auxiliary instance.
2. Configure any channels required for the TSPITR on the target instance.
Note: The auxiliary instance will use the same channel configuration as the target instance when performing the TSPITR.
3. Use TS_PITR_CHECK view for identifying and resolving dependencies within the recovery set tablespaces.
Refer to:
RMAN Tablespace Point-in-Time Recovery (TSPITR)
Case Studies
The following case studies give the audience detailed steps in building a test environment and in practicing the procedure.
Setting up the environment:
1. Created a tablespace test and a table in that tablespace
SQL> CREATE TABLESPACE TEST DATAFILE 'D:\BACKUP\TEST.DBF' size 2 M;
SQL> CREATE TABLE TEST001 (id number) TABLESPACE TEST;
SQL> INSERT INTO TEST001 VALUES(100);
1 row created.
SQL> COMMIT;
SQL> SELECT * FROM TEST001;
ID
----------
100
2. Checked the CURRENT LOG Sequence
SQL> SELECT SEQUENCE# FROM V$LOG WHERE STATUS='CURRENT';
SEQUENCE#
----------
135
Sequence# 135 is my current log sequence 3. Take a backup of the database and current controlfile using RMAN.
4. Do a few log switches and drop the table.
SQL> DROP TABLE TEST001;
SQL> SELECT SEQUENCE# FROM V$LOG
WHERE STATUS='CURRENT';
SEQUENCE
----------
139
Table was dropped in log sequence 139. So TSPITR until log sequence 138 will give the table back.
Note: UNTIL TIME TSPITR syntax is :
RMAN> recover tablespace "TEST" until time "23-SEP-2005 10:00:00','DD-MON-YYYY HH24:MI:SS" auxiliary destination 'D:\Backup\temp';
True test starts
1. Connect to RMAN
C:> rman target / catalog <catalog schema>/<password>
2. Now run TSPITR until log sequence 138. Auxiliary destination is D:\Backup\temp.
RMAN> RECOVER TABLESPACE "TEST" UNTIL LOGSEQ 138 THREAD 1 AUXILIARY DESTINATION 'D:\Backup\temp';
Starting recover at 20-SEP-05
starting full resync of recovery catalog
full resync complete
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=26 devtype=DISK
Creating automatic instance, with SID='ljsA'
initialization parameters used for automatic instance:
db_name=prod
compatible=10.2.0.1.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_prod_ljsA
large_pool_size=1M
shared_pool_size=110M
#No auxiliary parameter file used
db_create_file_dest=D:\Backup\temp
control_files=D:\Backup\temp\cntrl_tspitr_prod_ljsA.f
starting up automatic instance prod
Oracle instance started
Total System Global Area 201326592 bytes
Fixed Size 1247044 bytes
Variable Size 146802876 bytes
Database Buffers 50331648 bytes
Redo Buffers 2945024 bytes
Automatic instance created
contents of Memory Script:
{
# set the until clause
set until logseq 138 thread 1;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log for tspitr to a resent until time
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
# resync catalog after controlfile restore
resync catalog;
}
executing Memory Script
executing command: SET until clause
Starting restore at 20-SEP-05
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=36 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece
+DATA/prod/backupset/2005_09_20/ncnnf0_tag20050920t105610_0.291.569501773
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=+DATA/prod/backupset/2005_09_20/ncnnf0_tag20050920t105610_0.291.569501773
tag=TAG20050920T105610
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
output filename=D:\BACKUP\TEMP\CNTRL_TSPITR_PROD_LJSA.F
Finished restore at 20-SEP-05
sql statement: alter database mount clone database
sql statement: alter system archive log current
sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
starting full resync of recovery catalog
full resync complete
released channel: ORA_DISK_1
released channel: ORA_AUX_DISK_1
contents of Memory Script:
{
# generated tablespace point-in-time recovery script
# set the until clause
set until logseq 138 thread 1;
plsql <declare
sqlstatement varchar2(512);
offline_not_needed exception;
pragma exception_init(offline_not_needed, -01539);
begin
sqlstatement := 'alter tablespace '|| 'TEST' ||' offline for recover';
krmicd.writeMsg(6162, sqlstatement);
krmicd.execSql(sqlstatement);
exception
when offline_not_needed then
null;
end; >>>;
# set an omf destination filename for restore
set newname for clone datafile 1 to new;
# set an omf destination filename for restore
set newname for clone datafile 2 to new;
# set an omf destination tempfile
set newname for clone tempfile 1 to new;
# set a destination filename for restore
set newname for datafile 6 to
"D:\BACKUP\TEST.DBF";
# rename all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set plus the auxilliary tablespaces
restore clone datafile 1, 2, 6;
switch clone datafile all;
#online the datafiles restored or flipped
sql clone "alter database datafile 1 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 2 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 6 online";
# make the controlfile point at the restored datafiles, then recover them recover clone database tablespace "TEST", "SYSTEM", "UNDOTBS1" delete archivelog;
alter clone database open resetlogs;
# PLUG HERE the creation of a temporary tablespace if export fails due to lack # of temporary space.
## For example in Unix these two lines would do that:
#sql clone "create tablespace aux_tspitr_tmp
# datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K"; }
executing Memory Script executing command:
SET until clause sql statement: alter tablespace TEST offline for recover executing command:
SET NEWNAME executing command:
SET NEWNAME executing command:
SET NEWNAME executing command:
SET NEWNAME renamed temporary file 1 to D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_TEMP_%U_.TMP in control file
Starting restore at 20-SEP-05 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: sid=39 devtype=DISK channel ORA_AUX_DISK_1:
starting datafile backupset restore channel ORA_AUX_DISK_1:
specifying datafile(s) to restore from backup set restoring datafile 00001 to D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_SYSTEM_%U_.DBF
restoring datafile 00002 to D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_UNDOTBS1_%U_.DBF
restoring datafile 00006 to D:\BACKUP\TEST.DBF channel ORA_AUX_DISK_1:
reading from backup piece +DATA/PROD/backupset/2005_09_20/nnndf0_tag20050920t105434_0.295.569501677 channel ORA_AUX_DISK_1:
restored backup piece 1 piece handle=+DATA/prod/backupset/2005_09_20/nnndf0_tag20050920t105434_0.295.569501677 tag=TAG20050920T105434 channel ORA_AUX_DISK_1:
restore complete, elapsed time: 00:01:06
Finished restore at 20-SEP-05
datafile 1 switched to datafile copy input datafile copy recid=4 stamp=569503256 filename=D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_SYSTEM_1LZ8QZF1_.DBF
datafile 2 switched to datafile copy input datafile copy recid=5 stamp=569503256 filename=D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_UNDOTBS1_1LZ8QZN7_.DBF
sql statement:
alter database datafile 1 online sql statement:
alter database datafile 2 online sql statement:
alter database datafile 6 online
Starting recover at 20-SEP-05 using channel ORA_AUX_DISK_1
starting media recovery
archive log thread 1 sequence 134 is already on disk as file +DATA/PROD/archivelog/2005_09_20/thread_1_seq_134.292.569501807
archive log thread 1 sequence 135 is already on disk as file +DATA/PROD/archivelog/2005_09_20/thread_1_seq_135.280.569501919
archive log thread 1 sequence 136 is already on disk as file +DATA/PROD/archivelog/2005_09_20/thread_1_seq_136.283.569501925
archive log thread 1 sequence 137 is already on disk as file +DATA/PROD/archivelog/2005_09_20/thread_1_seq_137.297.569501931 archive log filename=+DATA/prod/archivelog/2005_09_20/thread_1_seq_134.292.569501807 thread=1 sequence=134
archive log filename=+DATA/PROD/archivelog/2005_09_20/thread_1_seq_135.280.569501919 thread=1 sequence=135
archive log filename=+DATA/PROD/archivelog/2005_09_20/thread_1_seq_136.283.569501925 thread=1 sequence=136
archive log filename=+DATA/PROD/archivelog/2005_09_20/thread_1_seq_137.297.569501931 thread=1 sequence=137
media recovery complete, elapsed time: 00:00:06
Finished recover at 20-SEP-05
database opened contents of Memory Script:
{
# export the tablespaces in the recovery set host 'exp userid =\"/@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=oracle)(ARGV0=oracleljsA)(ARGS=^'(DESCRIPTION=(LO AL=YES)(ADDRESS=(PROTOCOL=beq)))^')(ENVS=^'ORACLE_SID=ljsA^'))(CONNECT_DATA=(SID=ljsA))) as sysdba\" point_in_time_recover=y tablespaces= TEST file= tspitr_a.dmp';
# shutdown clone before import shutdown clone immediate
# import the tablespaces in the recovery set host 'imp userid =\"/@ as sysdba\" point_in_time_recover=y file= tspitr_a.dmp';
# online/offline the tablespace imported sql "alter tablespace TEST online"; sql "alter tablespace TEST offline";
# enable autobackups in case user does open resetlogs from RMAN after TSPITR sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
# resync catalog after tspitr finished resync catalog;
}
executing Memory Script Export: Release 10.2.0.1.0 - Production on Tue Sep 20 11:21:40 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Produc tion With the Partitioning, OLAP and Data Mining options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character
set server uses AL32UTF8 character set (possible charset conversion)
Note: table data (rows) will not be exported
About to export Tablespace Point-in-time Recovery objects...
For tablespace TEST ... .
exporting cluster definitions .
exporting table definitions . .
exporting table TEST001 .
exporting referential integrity constraints .
exporting triggers .
end point-in-time recovery
Export terminated successfully without warnings.
host command complete
database closed
database dismounted
Oracle instance shut down
Import: Release 10.2.0.1.0 - Production on Tue Sep 20 11:22:17 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via conventional path
About to import Tablespace Point-in-time Recovery objects...
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character
set import server uses AL32UTF8 character set (possible charset conversion) .
importing SYS's objects into SYS . .
importing table "TEST001"
Import terminated successfully without warnings.
host command complete
sql statement: alter tablespace TEST online
sql statement: alter tablespace TEST offline
sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;
starting full resync of recovery catalog full resync complete
Removing automatic instance
Automatic instance removed
auxiliary instance file D:\BACKUP\TEMP\CNTRL_TSPITR_PROD_LJSA.F deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_SYSTEM_1LZ8QZF1_.DBF deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_UNDOTBS1_1LZ8QZN7_.DBF deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\DATAFILE\O1_MF_TEMP_1LZ8TSLB_.TMP deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\ONLINELOG\O1_MF_1_1LZ8TM4X_.LOG deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\ONLINELOG\O1_MF_2_1LZ8TMSL_.LOG deleted
auxiliary instance file D:\BACKUP\TEMP\TSPITR_A\ONLINELOG\O1_MF_3_1LZ8TNCV_.LOG deleted
Finished recover at 20-SEP-05
TSPITR recovery completed sucessfully.
3. Connect to target database using SQLPLUS, put tablespace test online and check contents:
SQL>ALTER TABLESPACE TEST ONLINE;
SQL> SELECT * FROM TEST001;
ID
----------
100
Recovered the lost table using TSPITR.
---------------------------测试19 C--------------
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB READ WRITE YES
SQL> CREATE TABLESPACE TEST;
Tablespace created.
SQL> CREATE TABLE TEST001 (id number) TABLESPACE TEST;
Table created.
SQL> INSERT INTO TEST001 VALUES(100);
1 row created.
SQL> SELECT * FROM TEST001;
ID
----------
100
SQL> SELECT SEQUENCE# FROM V$LOG WHERE STATUS='CURRENT';
SEQUENCE#
----------
1
SQL> SELECT inst_id, group#,SEQUENCE# ,thread# FROM gV$LOG WHERE STATUS='CURRENT';
INST_ID GROUP# SEQUENCE# THREAD#
---------- ---------- ---------- ----------
3 5 11 3
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0
[oracle@rac3 ~]$ rman target / --------------------not SQLPLUS!!!!!!!!
Recovery Manager: Release 19.0.0.0.0 - Production on Sun Jul 7 04:19:32 2024
Version 19.20.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB (DBID=2265125454)
RMAN> backup database;
Starting backup at 07-JUL-24
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=28 instance=cdb3 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/CDB/DATAFILE/system.347.1173663209
input datafile file number=00003 name=+DATA/CDB/DATAFILE/sysaux.269.1173663209
input datafile file number=00004 name=+DATA/CDB/DATAFILE/undotbs1.267.1173663209
input datafile file number=00009 name=+DATA/CDB/DATAFILE/undotbs2.270.1173663209
input datafile file number=00017 name=+DATA/CDB/DATAFILE/test.363.1173673135
input datafile file number=00010 name=+DATA/CDB/DATAFILE/undotbs3.265.1173663209
input datafile file number=00007 name=+DATA/CDB/DATAFILE/users.268.1173663209
channel ORA_DISK_1: starting piece 1 at 07-JUL-24
channel ORA_DISK_1: finished piece 1 at 07-JUL-24
piece handle=+DATA1/CDB/BACKUPSET/2024_07_07/nnndf0_tag20240707t041936_0.300.1173673177 tag=TAG20240707T041936 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00011 name=+DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/system.287.1173663255
input datafile file number=00012 name=+DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/sysaux.261.1173663255
input datafile file number=00013 name=+DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/undotbs1.274.1173663255
input datafile file number=00014 name=+DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/undo_3.360.1173663255
input datafile file number=00015 name=+DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/undo_4.275.1173663255
input datafile file number=00016 name=+DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/users.282.1173663255
channel ORA_DISK_1: starting piece 1 at 07-JUL-24
channel ORA_DISK_1: finished piece 1 at 07-JUL-24
piece handle=+DATA1/CDB/06344F62B8C65A17E0636401A8C0F073/BACKUPSET/2024_07_07/nnndf0_tag20240707t041936_0.355.1173673179 tag=TAG20240707T041936 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=+DATA/CDB/0633F844101D69CBE0636401A8C09D55/DATAFILE/system.293.1173663279
input datafile file number=00006 name=+DATA/CDB/0633F844101D69CBE0636401A8C09D55/DATAFILE/sysaux.258.1173663279
input datafile file number=00008 name=+DATA/CDB/0633F844101D69CBE0636401A8C09D55/DATAFILE/undotbs1.284.1173663279
channel ORA_DISK_1: starting piece 1 at 07-JUL-24
channel ORA_DISK_1: finished piece 1 at 07-JUL-24
piece handle=+DATA1/CDB/0633F844101D69CBE0636401A8C09D55/BACKUPSET/2024_07_07/nnndf0_tag20240707t041936_0.317.1173673183 tag=TAG20240707T041936 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 07-JUL-24
Starting Control File and SPFILE Autobackup at 07-JUL-24
piece handle=+DATA1/CDB/AUTOBACKUP/2024_07_07/s_1173673185.360.1173673185 comment=NONE
Finished Control File and SPFILE Autobackup at 07-JUL-24
RMAN> exit
Recovery Manager complete.
[oracle@rac3 ~]$ s
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Jul 7 04:19:48 2024
Version 19.20.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0
SQL> alter system switch logfile;----!!!!!!!!
/ / / /
System altered.
System altered.
System altered.
SQL>create table TEST002 (id number) TABLESPACE TEST;-----test test002 disappear
Table created.
SQL> SELECT inst_id, group#,SEQUENCE# ,thread# FROM gV$LOG WHERE STATUS='CURRENT';
INST_ID GROUP# SEQUENCE# THREAD#
---------- ---------- ---------- ----------
3 6 16 3
SQL> DROP TABLE TEST001;
Table dropped.
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0
[oracle@rac3 ~]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Sun Jul 7 04:21:04 2024
Version 19.20.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB (DBID=2265125454)
RMAN> RECOVER TABLESPACE "TEST" UNTIL LOGSEQ 16 THREAD 3 AUXILIARY DESTINATION '+data1'; -----!!!!!!!16 not 11 ,thread 3 not 1 ,"TEST" not TEST
RMAN> RECOVER TABLESPACE "TEST" UNTIL LOGSEQ 16 THREAD 3 AUXILIARY DESTINATION '+data1';
Starting recover at 07-JUL-24
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=51 instance=cdb3 device type=DISK
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
Tablespace UNDOTBS2
Tablespace UNDOTBS3
Creating automatic instance, with SID='Cyyx'
initialization parameters used for automatic instance:
db_name=CDB
db_unique_name=Cyyx_pitr_CDB
compatible=19.0.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_pdb_name_case_sensitive=false
_system_trig_enabled=FALSE
sga_target=2272M
processes=200
db_create_file_dest=+data1
log_archive_dest_1='location=+data1'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB
Oracle instance started
Total System Global Area 2382363816 bytes
Fixed Size 9165992 bytes
Variable Size 520093696 bytes
Database Buffers 1845493760 bytes
Redo Buffers 7610368 bytes
Automatic instance created
Running TRANSPORT_SET_CHECK on recovery set tablespaces
TRANSPORT_SET_CHECK completed successfully
contents of Memory Script:
{
# set requested point in time
set until logseq 16 thread 3;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script
executing command: SET until clause
Starting restore at 07-JUL-24
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=23 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 +DATA1/CDB/AUTOBACKUP/2024_07_07/s_1173674427.300.1173674427
channel ORA_AUX_DISK_1: piece handle=+DATA1/CDB/AUTOBACKUP/2024_07_07/s_1173674427.300.1173674427 tag=TAG20240707T044027
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
output file name=+DATA1/CDB/CONTROLFILE/current.408.1173674641
Finished restore at 07-JUL-24
sql statement: alter database mount clone database
sql statement: alter system archive log current
sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
contents of Memory Script:
{
# set requested point in time
set until logseq 16 thread 3;
plsql <<<--
declare
sqlstatement varchar2(512);
pdbname varchar2(128);
offline_not_needed exception;
pragma exception_init(offline_not_needed, -01539);
begin
pdbname := null; -- pdbname
sqlstatement := 'alter tablespace '|| '"TEST"' ||' offline immediate';
krmicd.writeMsg(6162, sqlstatement);
krmicd.execSql(sqlstatement, 0, pdbname);
exception
when offline_not_needed then
null;
end; >>>;
# 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 9 to new;
set newname for clone datafile 10 to new;
set newname for clone datafile 3 to new;
set newname for clone tempfile 1 to new;
set newname for datafile 19 to
"+DATA/CDB/DATAFILE/test.363.1173674275";
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 9, 10, 3, 19;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
sql statement: alter tablespace "TEST" offline immediate
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to +data1 in control file
Starting restore at 07-JUL-24
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 +data1
channel ORA_AUX_DISK_1: restoring datafile 00004 to +data1
channel ORA_AUX_DISK_1: restoring datafile 00009 to +data1
channel ORA_AUX_DISK_1: restoring datafile 00010 to +data1
channel ORA_AUX_DISK_1: restoring datafile 00003 to +data1
channel ORA_AUX_DISK_1: restoring datafile 00019 to +DATA/CDB/DATAFILE/test.363.1173674275
channel ORA_AUX_DISK_1: reading from backup piece +DATA1/CDB/BACKUPSET/2024_07_07/nnndf0_tag20240707t044017_0.360.1173674417
channel ORA_AUX_DISK_1: piece handle=+DATA1/CDB/BACKUPSET/2024_07_07/nnndf0_tag20240707t044017_0.360.1173674417 tag=TAG20240707T044017
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 07-JUL-24
datafile 1 switched to datafile copy
input datafile copy RECID=30 STAMP=1173674654 file name=+DATA1/CDB/DATAFILE/system.384.1173674647
datafile 4 switched to datafile copy
input datafile copy RECID=31 STAMP=1173674654 file name=+DATA1/CDB/DATAFILE/undotbs1.350.1173674647
datafile 9 switched to datafile copy
input datafile copy RECID=32 STAMP=1173674654 file name=+DATA1/CDB/DATAFILE/undotbs2.357.1173674647
datafile 10 switched to datafile copy
input datafile copy RECID=33 STAMP=1173674654 file name=+DATA1/CDB/DATAFILE/undotbs3.338.1173674647
datafile 3 switched to datafile copy
input datafile copy RECID=34 STAMP=1173674654 file name=+DATA1/CDB/DATAFILE/sysaux.418.1173674647
contents of Memory Script:
{
# set requested point in time
set until logseq 16 thread 3;
# 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 9 online";
sql clone "alter database datafile 10 online";
sql clone "alter database datafile 3 online";
sql clone "alter database datafile 19 online";
# recover and open resetlogs
recover clone database tablespace "TEST", "SYSTEM", "UNDOTBS1", "UNDOTBS2", "UNDOTBS3", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
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 9 online
sql statement: alter database datafile 10 online
sql statement: alter database datafile 3 online
sql statement: alter database datafile 19 online
Starting recover at 07-JUL-24
using channel ORA_AUX_DISK_1
Executing: alter database datafile 7 offline
Executing: alter database datafile 5, 6, 8 offline
Executing: alter database datafile 11, 12, 13, 14, 15, 16 offline
starting media recovery
archived log for thread 3 with sequence 11 is already on disk as file +DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_11.353.1173674485
archived log for thread 3 with sequence 12 is already on disk as file +DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_12.417.1173674487
archived log for thread 3 with sequence 13 is already on disk as file +DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_13.359.1173674491
archived log for thread 3 with sequence 14 is already on disk as file +DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_14.404.1173674491
archived log for thread 3 with sequence 15 is already on disk as file +DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_15.343.1173674493
archived log file name=+DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_11.353.1173674485 thread=3 sequence=11
archived log file name=+DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_12.417.1173674487 thread=3 sequence=12
archived log file name=+DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_13.359.1173674491 thread=3 sequence=13
archived log file name=+DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_14.404.1173674491 thread=3 sequence=14
archived log file name=+DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_15.343.1173674493 thread=3 sequence=15
media recovery complete, elapsed time: 00:00:02
Finished recover at 07-JUL-24
database opened
contents of Memory Script:
{
# make read only the tablespace that will be exported
sql clone 'alter tablespace "TEST" read only';
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
+data1''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
+data1''";
}
executing Memory Script
sql statement: alter tablespace "TEST" read only
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''+data1''
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''+data1''
Performing export of metadata...
EXPDP>
Warning: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.
EXPDP> Starting "SYS"."TSPITR_EXP_Cyyx_jqEk":
EXPDP> ORA-39327: Oracle Database Vault data is being stored unencrypted in dump file set.
EXPDP> Processing object type TRANSPORTABLE_EXPORT/STATISTICS/TABLE_STATISTICS
EXPDP> Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
EXPDP> Master table "SYS"."TSPITR_EXP_Cyyx_jqEk" successfully loaded/unloaded
EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TSPITR_EXP_Cyyx_jqEk is:
EXPDP> +DATA1/tspitr_cyyx_14541.dmp
EXPDP> ******************************************************************************
EXPDP> Datafiles required for transportable tablespace TEST:
EXPDP> +DATA/CDB/DATAFILE/test.363.1173674275
EXPDP> Job "SYS"."TSPITR_EXP_Cyyx_jqEk" completed with 1 error(s) at Sun Jul 7 04:44:45 2024 elapsed 0 00:00:19
Export completed
contents of Memory Script:
{
# shutdown clone before import
shutdown clone abort
# drop target tablespaces before importing them back
sql 'drop tablespace "TEST" including contents keep datafiles cascade constraints';
}
executing Memory Script
Oracle instance shut down
sql statement: drop tablespace "TEST" including contents keep datafiles cascade constraints
Performing import of metadata...--------------!!!
IMPDP>
Warning: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.
IMPDP> Master table "SYS"."TSPITR_IMP_Cyyx_cxin" successfully loaded/unloaded
IMPDP> Starting "SYS"."TSPITR_IMP_Cyyx_cxin":
IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
IMPDP> Processing object type TRANSPORTABLE_EXPORT/STATISTICS/TABLE_STATISTICS
IMPDP> Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
IMPDP> Job "SYS"."TSPITR_IMP_Cyyx_cxin" successfully completed at Sun Jul 7 04:45:05 2024 elapsed 0 00:00:14
Import completed
contents of Memory Script:
{
# make read write and offline the imported tablespaces
sql 'alter tablespace "TEST" read write';
sql 'alter tablespace "TEST" offline';
# enable autobackups after TSPITR is finished
sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
}
executing Memory Script
sql statement: alter tablespace "TEST" read write
sql statement: alter tablespace "TEST" offline
sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;
Removing automatic instance
Automatic instance removed
auxiliary instance file +DATA1/CDB/TEMPFILE/temp.351.1173674661 deleted
auxiliary instance file +DATA1/CDB/ONLINELOG/group_6.283.1173674659 deleted
auxiliary instance file +DATA1/CDB/ONLINELOG/group_5.284.1173674659 deleted
auxiliary instance file +DATA1/CDB/ONLINELOG/group_4.295.1173674659 deleted
auxiliary instance file +DATA1/CDB/ONLINELOG/group_3.294.1173674659 deleted
auxiliary instance file +DATA1/CDB/ONLINELOG/group_2.307.1173674659 deleted
auxiliary instance file +DATA1/CDB/ONLINELOG/group_1.335.1173674659 deleted
auxiliary instance file +DATA1/CDB/DATAFILE/sysaux.418.1173674647 deleted
auxiliary instance file +DATA1/CDB/DATAFILE/undotbs3.338.1173674647 deleted
auxiliary instance file +DATA1/CDB/DATAFILE/undotbs2.357.1173674647 deleted
auxiliary instance file +DATA1/CDB/DATAFILE/undotbs1.350.1173674647 deleted
auxiliary instance file +DATA1/CDB/DATAFILE/system.384.1173674647 deleted
auxiliary instance file +DATA1/CDB/CONTROLFILE/current.408.1173674641 deleted
auxiliary instance file tspitr_Cyyx_14541.dmp deleted
Finished recover at 07-JUL-24
RMAN> report schema;
Report of database schema for database with db_unique_name CDB
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 1170 SYSTEM YES +DATA/CDB/DATAFILE/system.347.1173663209
3 920 SYSAUX NO +DATA/CDB/DATAFILE/sysaux.269.1173663209
4 615 UNDOTBS1 YES +DATA/CDB/DATAFILE/undotbs1.267.1173663209
5 510 PDB$SEED:SYSTEM NO +DATA/CDB/0633F844101D69CBE0636401A8C09D55/DATAFILE/system.293.1173663279
6 480 PDB$SEED:SYSAUX NO +DATA/CDB/0633F844101D69CBE0636401A8C09D55/DATAFILE/sysaux.258.1173663279
7 5 USERS NO +DATA/CDB/DATAFILE/users.268.1173663209
8 215 PDB$SEED:UNDOTBS1 NO +DATA/CDB/0633F844101D69CBE0636401A8C09D55/DATAFILE/undotbs1.284.1173663279
9 250 UNDOTBS2 YES +DATA/CDB/DATAFILE/undotbs2.270.1173663209
10 75 UNDOTBS3 YES +DATA/CDB/DATAFILE/undotbs3.265.1173663209
11 510 PDB:SYSTEM NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/system.287.1173663255
12 490 PDB:SYSAUX NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/sysaux.261.1173663255
13 215 PDB:UNDOTBS1 NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/undotbs1.274.1173663255
14 215 PDB:UNDO_3 NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/undo_3.360.1173663255
15 215 PDB:UNDO_4 NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/undo_4.275.1173663255
16 5 PDB:USERS NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/users.282.1173663255
20 0 TEST NO +DATA/CDB/DATAFILE/test.363.1173674275------------------------!!!!!!!!!!!!size 0
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 22 TEMP 32767 +DATA/CDB/TEMPFILE/temp.263.1173663343
2 36 PDB$SEED:TEMP 32767 +DATA/CDB/0633F844101D69CBE0636401A8C09D55/TEMPFILE/temp.264.1173663347
RMAN>
------------------ not like restore , recover will change datafile id
SQL> SELECT * FROM TEST001;
SELECT * FROM TEST001
*
ERROR at line 1:
ORA-00376: file 18 cannot be read at this time
ORA-01110: data file 18: '+DATA/CDB/DATAFILE/test.363.1173673135'
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01124: cannot recover data file 1 - file is in use or recovery
ORA-01110: data file 1: '+DATA/CDB/DATAFILE/system.347.1173663209'
RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name CDB
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 1170 SYSTEM YES +DATA/CDB/DATAFILE/system.347.1173663209
3 910 SYSAUX NO +DATA/CDB/DATAFILE/sysaux.269.1173663209
4 615 UNDOTBS1 YES +DATA/CDB/DATAFILE/undotbs1.267.1173663209
5 510 PDB$SEED:SYSTEM NO +DATA/CDB/0633F844101D69CBE0636401A8C09D55/DATAFILE/system.293.1173663279
6 480 PDB$SEED:SYSAUX NO +DATA/CDB/0633F844101D69CBE0636401A8C09D55/DATAFILE/sysaux.258.1173663279
7 5 USERS NO +DATA/CDB/DATAFILE/users.268.1173663209
8 215 PDB$SEED:UNDOTBS1 NO +DATA/CDB/0633F844101D69CBE0636401A8C09D55/DATAFILE/undotbs1.284.1173663279
9 250 UNDOTBS2 YES +DATA/CDB/DATAFILE/undotbs2.270.1173663209
10 75 UNDOTBS3 YES +DATA/CDB/DATAFILE/undotbs3.265.1173663209
11 510 PDB:SYSTEM NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/system.287.1173663255
12 490 PDB:SYSAUX NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/sysaux.261.1173663255
13 215 PDB:UNDOTBS1 NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/undotbs1.274.1173663255
14 215 PDB:UNDO_3 NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/undo_3.360.1173663255
15 215 PDB:UNDO_4 NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/undo_4.275.1173663255
16 5 PDB:USERS NO +DATA/CDB/06344F62B8C65A17E0636401A8C0F073/DATAFILE/users.282.1173663255
18 0 TEST NO +DATA/CDB/DATAFILE/test.363.1173673135
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 22 TEMP 32767 +DATA/CDB/TEMPFILE/temp.263.1173663343
2 36 PDB$SEED:TEMP 32767 +DATA/CDB/0633F844101D69CBE0636401A8C09D55/TEMPFILE/temp.264.1173663347
*
ERROR at line 1:
ORA-00376: file 18 cannot be read at this time
ORA-01110: data file 18: '+DATA/CDB/DATAFILE/test.363.1173673135'
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0
[oracle@rac3 ~]$ rman target /
RMAN> recover tablespace "TEST";
Starting recover at 07-JUL-24
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=66 instance=cdb3 device type=DISK
starting media recovery
media recovery failed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/07/2024 04:31:09
ORA-00283: recovery session canceled due to errors
RMAN-11003: failure during parse/execution of SQL statement: alter database recover
if needed datafile 18
ORA-00283: recovery session canceled due to errors
ORA-01124: cannot recover data file 18 - file is in use or recovery
ORA-01110: data file 18: '+DATA/CDB/DATAFILE/test.363.1173673135'
RMAN> alter tablespace test offline;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 07/07/2024 04:31:25
ORA-01539: tablespace 'TEST' is not online
RMAN> recover tablespace "TEST" ;
Starting recover at 07-JUL-24
using channel ORA_DISK_1
starting media recovery
media recovery failed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/07/2024 04:31:48
ORA-00283: recovery session canceled due to errors
RMAN-11003: failure during parse/execution of SQL statement: alter database recover
if needed datafile 18
ORA-00283: recovery session canceled due to errors
ORA-01124: cannot recover data file 18 - file is in use or recovery
ORA-01110: data file 18: '+DATA/CDB/DATAFILE/test.363.1173673135'
RMAN> alter tablespace test online;
Statement processed
RMAN> select *from TEST001;
ID
----------
100
RMAN> select *from TEST002;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 07/07/2024 04:32:20
ORA-00942: table or view does not exist
RMAN> exit
Recovery Manager complete.
[oracle@rac3 ~]$ s
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Jul 7 04:32:37 2024
Version 19.20.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0
SQL> SELECT * FROM TEST001;
ID
----------
100
SQL> SELECT * FROM TEST002;
SELECT * FROM TEST002
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0
[oracle@rac3 ~]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Sun Jul 7 04:33:00 2024
Version 19.20.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB (DBID=2265125454)
RMAN>
---------------------- test again
RMAN> SELECT * FROM TEST001;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 07/07/2024 04:46:46
ORA-00376: file 20 cannot be read at this time
ORA-01110: data file 20: '+DATA/CDB/DATAFILE/test.363.1173674275'
RMAN> alter database datafile 18 online;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 07/07/2024 04:49:25
ORA-01516: nonexistent log file, data file, or temporary file "18" in the current container
RMAN> alter tablespace test online;
Statement processed
RMAN> SELECT * FROM TEST001;
ID
----------
100
RMAN> SELECT * FROM TEST002;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 07/07/2024 04:51:17
ORA-00942: table or view does not exist
RMAN>
---------------------------不能再次恢复了--expdp 导出数据字典,沿用旧的datafile-----------------------
RMAN> RECOVER TABLESPACE "TEST" UNTIL LOGSEQ 16 THREAD 3 AUXILIARY DESTINATION '+data1';
Starting recover at 07-JUL-24
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
Tablespace UNDOTBS2
Tablespace UNDOTBS3
Creating automatic instance, with SID='qsCl'
initialization parameters used for automatic instance:
db_name=CDB
db_unique_name=qsCl_pitr_CDB
compatible=19.0.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_pdb_name_case_sensitive=false
_system_trig_enabled=FALSE
sga_target=2272M
processes=200
db_create_file_dest=+data1
log_archive_dest_1='location=+data1'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB
Oracle instance started
Total System Global Area 2382363816 bytes
Fixed Size 9165992 bytes
Variable Size 520093696 bytes
Database Buffers 1845493760 bytes
Redo Buffers 7610368 bytes
Automatic instance created
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/07/2024 04:52:32
RMAN-05002: aborting Tablespace Point-in-Time Recovery
RMAN-05073: Tablespace TEST creation SCN 7627742 is ahead of point-in-time SCN 7626106
RMAN> RECOVER TABLESPACE "TEST" UNTIL LOGSEQ 17 THREAD 3 AUXILIARY DESTINATION '+data1';
Starting recover at 07-JUL-24
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
Tablespace UNDOTBS2
Tablespace UNDOTBS3
Creating automatic instance, with SID='wgkE'
initialization parameters used for automatic instance:
db_name=CDB
db_unique_name=wgkE_pitr_CDB
compatible=19.0.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_pdb_name_case_sensitive=false
_system_trig_enabled=FALSE
sga_target=2272M
processes=200
db_create_file_dest=+data1
log_archive_dest_1='location=+data1'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB
Oracle instance started
Total System Global Area 2382363816 bytes
Fixed Size 9165992 bytes
Variable Size 520093696 bytes
Database Buffers 1845493760 bytes
Redo Buffers 7610368 bytes
Automatic instance created
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/07/2024 04:52:51
RMAN-05002: aborting Tablespace Point-in-Time Recovery
RMAN-05073: Tablespace TEST creation SCN 7627742 is ahead of point-in-time SCN 7626239
-------------基于时间 SCN的都不行
[oracle@rac3 ~]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Sun Jul 7 10:30:36 2024
Version 19.20.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB (DBID=2265125454)
RMAN> recover tablespace "TEST" until time "7-Jul-2024 04:20:04','DD-MON-YYYY HH24:MI:SS" auxiliary destination '+data1';
Starting recover at 07-JUL-24
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=71 instance=cdb3 device type=DISK
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
Tablespace UNDOTBS2
Tablespace UNDOTBS3
Creating automatic instance, with SID='DfBi'
initialization parameters used for automatic instance:
db_name=CDB
db_unique_name=DfBi_pitr_CDB
compatible=19.0.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_pdb_name_case_sensitive=false
_system_trig_enabled=FALSE
sga_target=2272M
processes=200
db_create_file_dest=+data1
log_archive_dest_1='location=+data1'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB
Oracle instance started
Total System Global Area 2382363816 bytes
Fixed Size 9165992 bytes
Variable Size 520093696 bytes
Database Buffers 1845493760 bytes
Redo Buffers 7610368 bytes
Automatic instance created
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/07/2024 10:31:08
RMAN-05002: aborting Tablespace Point-in-Time Recovery
RMAN-05073: Tablespace TEST creation SCN 7627742 is ahead of point-in-time SCN 7621085
----------------------
RMAN-05073: Tablespace TEST creation SCN 7627742 is ahead of point-in-time SCN 7626239
-----------------------
RMAN> recover tablespace "TEST" until scn 7627743 auxiliary destination '+data1';
Starting recover at 07-JUL-24
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
Tablespace UNDOTBS2
Tablespace UNDOTBS3
Creating automatic instance, with SID='mrEt'
initialization parameters used for automatic instance:
db_name=CDB
db_unique_name=mrEt_pitr_CDB
compatible=19.0.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_pdb_name_case_sensitive=false
_system_trig_enabled=FALSE
sga_target=2272M
processes=200
db_create_file_dest=+data1
log_archive_dest_1='location=+data1'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB
Oracle instance started
Total System Global Area 2382363816 bytes
Fixed Size 9165992 bytes
Variable Size 520093696 bytes
Database Buffers 1845493760 bytes
Redo Buffers 7610368 bytes
Automatic instance created
Running TRANSPORT_SET_CHECK on recovery set tablespaces
TRANSPORT_SET_CHECK completed successfully
contents of Memory Script:
{
# set requested point in time
set until scn 7627743;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script
executing command: SET until clause
Starting restore at 07-JUL-24
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=184 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 +DATA1/CDB/AUTOBACKUP/2024_07_07/s_1173674427.300.1173674427
channel ORA_AUX_DISK_1: piece handle=+DATA1/CDB/AUTOBACKUP/2024_07_07/s_1173674427.300.1173674427 tag=TAG20240707T044027
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
output file name=+DATA1/CDB/CONTROLFILE/current.350.1173695531
Finished restore at 07-JUL-24
sql statement: alter database mount clone database
sql statement: alter system archive log current
sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
contents of Memory Script:
{
# set requested point in time
set until scn 7627743;
plsql <<<--
declare
sqlstatement varchar2(512);
pdbname varchar2(128);
offline_not_needed exception;
pragma exception_init(offline_not_needed, -01539);
begin
pdbname := null; -- pdbname
sqlstatement := 'alter tablespace '|| '"TEST"' ||' offline immediate';
krmicd.writeMsg(6162, sqlstatement);
krmicd.execSql(sqlstatement, 0, pdbname);
exception
when offline_not_needed then
null;
end; >>>;
# 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 9 to new;
set newname for clone datafile 10 to new;
set newname for clone datafile 3 to new;
set newname for clone tempfile 1 to new;
set newname for datafile 20 to
"+DATA/CDB/DATAFILE/test.363.1173674275";
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 9, 10, 3, 20;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
sql statement: alter tablespace "TEST" offline immediate
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to +data1 in control file
Starting restore at 07-JUL-24
using channel ORA_AUX_DISK_1
One or more auxiliary set of datafiles could not be removed
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file +DATA1/CDB/CONTROLFILE/current.350.1173695531 deleted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/07/2024 10:32:25
RMAN-03015: error occurred in stored script Memory Script
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 20 found to restore
tablespace test遭到破坏
RMAN> select
2> * from test001;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 07/07/2024 10:37:24
ORA-00376: file 20 cannot be read at this time
ORA-01110: data file 20: '+DATA/CDB/DATAFILE/test.363.1173674275'
RMAN> alter tablespace test online;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 07/07/2024 10:37:38
ORA-01113: file 20 needs media recovery
ORA-01110: data file 20: '+DATA/CDB/DATAFILE/test.363.1173674275'
RMAN> recover datafile 20;
Starting recover at 07-JUL-24
using channel ORA_DISK_1
starting media recovery
archived log for thread 3 with sequence 18 is already on disk as file +DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_18.357.1173695537
archived log for thread 3 with sequence 19 is already on disk as file +DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_19.338.1173695737
archived log file name=+DATA1/CDB/ARCHIVELOG/2024_07_07/thread_3_seq_18.357.1173695537 thread=3 sequence=18
media recovery complete, elapsed time: 00:00:00
Finished recover at 07-JUL-24
RMAN> alter tablespace test online;
Statement processed
RMAN>
RMAN> select * from test001;
ID
----------
100
RMAN>