How to recover a skipped tablespace after an incomplete recovery? (Doc ID 1561645.1)

How to recover a skipped tablespace after an incomplete recovery? (Doc ID 1561645.1)

APPLIES TO:

Oracle Database - Enterprise Edition - Version 11.2.0.1 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.

GOAL

How to recover a skipped tablespace after an incomplete recovery.
How to restore skipped after incomplete recovery table space
Skipped datafile is reported offline after resetlogs is done from Incomplete recovery.
After the completion of resetlogs never fully recovered, the data file will be skipped reported as offline state

SQL> select * from V$recover_file;

FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
---------- ------- ------- ----------------------------------------------------------------- ---------- --------------------
6 OFFLINE OFFLINE UNKNOWN ERROR 2386984 13-JUN-2013 22:52:39

This Document holds good if you have a Valid backup of the skipped tablespace.
If you have a valid backup skipped table space, this book is very useful

SOLUTION

NOTE: In the images and/or the document content below, the user information and environment data used represents fictitious data from the Oracle sample schema(s), Public Documentation delivered with an Oracle database product or other training material. Any similarity to actual environments, actual persons, living or dead, is purely coincidental and not intended in any manner.

For the purposes of this document, the following fictitious environment is used as an example to describe the procedure:
Database Name: PRODDB
Tablespace Name:  PRODDATA
Directory Location:  u01/app/oradb1

********

It is possible to restore and recover a skipped tablespace even when the database has been opened with resetlogs.

Resetlogs even if the database is open, can also restore and recover skipped tablespace.

As a best practice we always recommend testing the backups, restore and recovery scenario in your environment.

As a best practice, we always recommend that you test your backup environment, reduction and recovery programs

In this note we will be skipping the tablespace PRODDATA

In this note, we will skip the table space PRODDATA

Database Structure and Backup   database structure and backup

Assume that we have the following tablespaces and a full backup is taken:

Suppose we have the following table space, and has been a full backup

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.

$ 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.   Have skipped the table space is not fully restored

Skip a tablespace during restore/recovery get the rest of the database online for use.

Skip Table space during restore / recovery, so that the rest of the database online use

$ 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;
}

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 resetlogs;

Database altered.

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.

SQL> select * from V$recover_file;

     FILE# ONLINE  ONLINE_ ERROR                                                                CHANGE# TIME
---------- ------- ------- ----------------------------------------------------------------- ---------- --------------------
         6 OFFLINE OFFLINE UNKNOWN ERROR                                                        2386984 13-JUN-2013 22:52:39

 

The skipped tablespace 'datafile' is offline  and all the other 'datafiles' are online. Skipped tablespace 'datafile' is in the offline state, while all other 'datafiles' are in the online state

# V$tablespace shows the Tablespace 'PRODDATA' is still defined in dictionary and available

V $ tablespace display space defined dictionary table still 'PRODDATA' and may be

SQL> select * from v$tablespace ;  

 

 

Performing recovery of the skipped tablespace. Executed skipped recovery tablespace

As the database incarnation increments after resetlogs, to pick up the new/current database incarnation you will need to re-initiate the rman session as below:

With the increase after resetlogs incarnation of the database to obtain the database incarnation new / current, you will need to re-start rman session, as shown below

$ 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

SQL>  select * from V$recover_file;

no rows selected

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.


SQL> alter tablespace proddata online;

Tablespace altered.

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 is performed till the earlier specified "set until" and tablespace can be brought online for use.

Do not fully recover all data files skipped table space, until the previously designated "set until" and table space can be used online

Guess you like

Origin www.cnblogs.com/zylong-sys/p/12004536.html