How to recover a skipped tablespace after an incomplete recovery with resetlogs? [ID 1561645.1]
Posted on 2013-06-17 11:21 半夏_Fanxiaobo 阅读(2519) 评论(0) 收藏 举报
n this Document
|
This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process and therefore has not been subject to an independent technical review. |
Applies to:
Oracle Database - Enterprise Edition - Version 11.2.0.3 and later
Information in this document applies to any platform.
Goal
How to recover a skipped tablespace after an incomplete recovery with resetlogs?
Solution
It is possible to restore and recover the database and skip a tablespace and open the database for use and than perform the restore and recovery for the skipped tablespace.
As a best practice we always recommend testing the backups, restore and recovery scenario in your environment.
Database Structure and Backup
21:33:13 SQL> select tablespace_name, file_name, status from dba_data_files order by 1;
TABLESPACE_NAME FILE_NAME STATUS
-------------------- ---------------------------------------------------------------------- ---------
EXAMPLE /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_example_8vg997t4_.dbf AVAILABLE
PRODDATA /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_proddata_8vg9jlk1_.dbf AVAILABLE
SYSAUX /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_sysaux_8vg997qs_.dbf AVAILABLE
SYSTEM /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_system_8vg997sd_.dbf AVAILABLE
UNDOTBS1 /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_undotbs1_8vg997wc_.dbf AVAILABLE
USERS /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_users_8vg997xp_.dbf AVAILABLE
USERS /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_users_8vg997vg_.dbf AVAILABLE
7 rows selected.
[oradb1@ls6n1 trace]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Thu Jun 13 22:43:27 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRODDB (DBID=552982679)
RMAN> backup database plus archivelog;
...
piece handle=/u01/app/oradb1/fast_recovery_area/PRODDB/backupset/2013_06_13/o1_mf_nnndf_TAG20130613T224932_8vmhywt8_.bkp tag=TAG20130613T224932 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
Finished backup at 13-JUN-13
Starting Control File and SPFILE Autobackup at 13-JUN-13
piece handle=/u01/app/oradb1/fast_recovery_area/PRODDB/autobackup/2013_06_13/o1_mf_s_818031037_8vmj0y3g_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 13-JUN-13
Incomplete Recovery with a skipped tablespace.
You may want to skip a tablespace during restore/recovery to save time and get the rest of the database online for use at the earliest.
[oradb1@ls6n1 trace]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Thu Jun 13 22:54:08 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRODDB (DBID=552982679, not open)
RMAN> run {
set until sequence 10;
restore database skip tablespace proddata;
recover database skip tablespace proddata;
}2> 3> 4> 5>
executing command: SET until clause
Starting restore at 13-JUN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 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 00001 to /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_system_8vg997sd_.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_sysaux_8vg997qs_.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_undotbs1_8vg997wc_.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_users_8vg997xp_.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_example_8vg997t4_.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_users_8vg997vg_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oradb1/fast_recovery_area/PRODDB/backupset/2013_06_13/o1_mf_nnndf_TAG20130613T222311_8vmgfhjm_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oradb1/fast_recovery_area/PRODDB/backupset/2013_06_13/o1_mf_nnndf_TAG20130613T222311_8vmgfhjm_.bkp tag=TAG20130613T222311
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:57
Finished restore at 13-JUN-13
Starting recover at 13-JUN-13
using channel ORA_DISK_1
Executing: alter database datafile 6 offline --->>> (This is the datafile for PRODDATA)
starting media recovery
archived log for thread 1 with sequence 8 is already on disk as file /u01/app/oradb1/fast_recovery_area/PRODDB/archivelog/2013_06_13/o1_mf_1_8_8vmghjn4_.arc
archived log for thread 1 with sequence 9 is already on disk as file /u01/app/oradb1/fast_recovery_area/PRODDB/archivelog/2013_06_13/o1_mf_1_9_8vmhrdnv_.arc
archived log file name=/u01/app/oradb1/fast_recovery_area/PRODDB/archivelog/2013_06_13/o1_mf_1_8_8vmghjn4_.arc thread=1 sequence=8
archived log file name=/u01/app/oradb1/fast_recovery_area/PRODDB/archivelog/2013_06_13/o1_mf_1_9_8vmhrdnv_.arc thread=1 sequence=9
media recovery complete, elapsed time: 00:00:00
Finished recover at 13-JUN-13
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
23:00:31 SQL> select file#, status from V$datafile;
FILE# STATUS
---------- -------
1 SYSTEM
2 ONLINE
3 ONLINE
4 ONLINE
5 ONLINE
6 OFFLINE
7 ONLINE
7 rows selected.
---------------
23:00:53 SQL> select * from V$recover_file;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
---------- ------- ------- ----------------------------------------------------------------- ---------- --------------------
6 OFFLINE OFFLINE UNKNOWN ERROR 2386984 13-JUN-2013 22:52:39
23:01:03 SQL> alter system switch logfile;
System altered.
23:01:33 SQL> /
System altered.
-->>> Other than the skipped tablespace all the other tablespaces are online for user.
RMAN> run {
restore tablespace proddata;
recover tablespace proddata;
}
RMAN>
Starting restore at 13-JUN-13
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/13/2013 23:02:23
RMAN-20021: database not set
RMAN-06019: could not translate tablespace name "proddata"
-->> As the database incarnation increments after resetlogs, to pick up the new/current database incarnation you can either re-initiate the rman session or use the below:
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 PRODDB 552982679 PARENT 1 17-SEP-11
2 2 PRODDB 552982679 PARENT 995548 16-APR-13
3 3 PRODDB 552982679 PARENT 1138135 17-APR-13
4 4 PRODDB 552982679 PARENT 2269710 12-JUN-13
5 5 PRODDB 552982679 CURRENT 2384123 13-JUN-13
RMAN> reset database to incarnation 5;
[oradb1@ls6n1 trace]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Thu Jun 13 23:03:24 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRODDB (DBID=552982679)
RMAN> run {
restore tablespace proddata;
recover tablespace proddata;
}
RMAN>
Starting restore at 13-JUN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 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 00006 to /u01/app/oradb1/oradata/PRODDB/datafile/o1_mf_proddata_8vg9jlk1_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oradb1/fast_recovery_area/PRODDB/backupset/2013_06_13/o1_mf_nnndf_TAG20130613T222311_8vmgfhjm_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oradb1/fast_recovery_area/PRODDB/backupset/2013_06_13/o1_mf_nnndf_TAG20130613T222311_8vmgfhjm_.bkp tag=TAG20130613T222311
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 13-JUN-13
RMAN>
Starting recover at 13-JUN-13
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 8 is already on disk as file /u01/app/oradb1/fast_recovery_area/PRODDB/archivelog/2013_06_13/o1_mf_1_8_8vmghjn4_.arc
archived log for thread 1 with sequence 9 is already on disk as file /u01/app/oradb1/fast_recovery_area/PRODDB/archivelog/2013_06_13/o1_mf_1_9_8vmhrdnv_.arc
archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oradb1/fast_recovery_area/PRODDB/archivelog/2013_06_13/o1_mf_1_1_8vmjofl8_.arc
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oradb1/fast_recovery_area/PRODDB/archivelog/2013_06_13/o1_mf_1_2_8vmjoh19_.arc
archived log file name=/u01/app/oradb1/fast_recovery_area/PRODDB/archivelog/2013_06_13/o1_mf_1_8_8vmghjn4_.arc thread=1 sequence=8
archived log file name=/u01/app/oradb1/fast_recovery_area/PRODDB/archivelog/2013_06_13/o1_mf_1_9_8vmhrdnv_.arc thread=1 sequence=9
media recovery complete, elapsed time: 00:00:00
Finished recover at 13-JUN-13
23:01:34 SQL> select * from V$recover_file;
no rows selected
23:04:53 SQL> select file#, status from V$datafile;
FILE# STATUS
---------- -------
1 SYSTEM
2 ONLINE
3 ONLINE
4 ONLINE
5 ONLINE
6 OFFLINE
7 ONLINE
7 rows selected.
23:05:01 SQL> alter tablespace proddata online;
Tablespace altered.
23:05:23 SQL> select file#, status from V$datafile;
FILE# STATUS
---------- -------
1 SYSTEM
2 ONLINE
3 ONLINE
4 ONLINE
5 ONLINE
6 ONLINE
7 ONLINE
7 rows selected.
Incomplete recovery of all datafiles of the skipped tablespace will be performed till the earlier specified "set until" and tablespace can be brought online for use.
---------------------
RECOVER DATABASE SKIP FOREVER TABLESPACE list_skipped_TS UNTIL TIME ...
see SKIP option in ora doc:
SKIP [FOREVER] TABLESPACE Specifies tablespaces that should not be recovered, which is useful for avoiding recovery of tablespaces containing only temporary data or for postponing recovery of some tablespaces. The SKIP clause takes the datafiles in the specified tablespaces offline before starting media recovery. These files are left offline after the media recovery is complete.
If you perform incomplete recovery, then SKIP is not allowed. Instead, use SKIP FOREVER, with the intention of dropping the skipped tablespaces after opening the database with the RESETLOGS option. The SKIP FOREVER clause causes RMAN to take the datafiles offline with the DROP option. Only use SKIP FOREVER when the specified tablespaces will be dropped after opening the database.
浙公网安备 33010602011771号