| Oracle® Database Backup and Recovery Advance
d User's Guide 10g Release 1 (10.1) Part Number B10734-01 |
Home Contents Index <
br>
Master Index![]() Feedback |
|
View PDF |
Recovery Manager (RMAN ) automatic tablespace point-in-time recovery (commonly abbreviated TSPITR) enables you to quickly recover one or more tablespaces in an Oracle database to an earlier time, without affecting the state of th e rest of the tablespaces and other objects in the database.
This chapter explains when you can and cannot use TSPITR, what RMAN actually does to your database during TSPITR, how to prepare a database for TSPITR, how to run TSPITR, and options for controlling the TSPITR process.
This chapter contains the following sections:
In or der to use TSPITR effectively, you need to understand what problems it can solve for you, what the major elements used in TSPITR are, what RMAN does during TSPITR, and limitations on when and how it can be applied.
Figure 10-1 illustrates the context within which TSPITR takes place , and a general outline of the process.
Text description of the illustration bradv032.gif p>
The figure contains the following entities:
There are four other important terms related to TSPITR, which will be used in the rest of this discussion:
The auxiliary ins tance has other files associated with it, such as a control file, parameter file, and online logs , but they are not part of the auxi liary set.
All of these terms will be referenced throughout the remainder of this chapter.
To perform TSPITR of the recovery set using RMAN and an automated a
uxiliary instance, you carry out the preparations for TSPITR described in "Planning and Preparing for
TSPITR", and then issue the RECOVER TABLESPACE command, specifying, at a minimum,
the tablespaces of the recovery set and the target time for the point-in-time recovery, and, if desired, an auxiliary destination as
well.
RMAN then carries out the following steps:
AUXILIARY DESTINATION argument of RECOVER TABLESPACE)RESETLOGS optionSWITCH commands on the target instance, so that the target database control file now po
ints to the datafiles in the recovery set that were just recovered at the auxiliary instance.At that point the TSPITR process is complete. The recovery set datafiles are returned to their conte nts at the specified point in time, and belong to the target database.
Like a table import, RMAN TSPITR enables you to recover a consistent data set; however, the data set recovered includes an entire tablespace rather than one object.
RMAN TSPITR is most useful for situat ions such as these:
TABLE statement;Note that, as with database point-in-time recovery (DBPITR), you canno t perform TSPITR if you do not have your archived redo logs. For databases running in NOARCHIVELOG mode, you cannot perform TSPITR. p>
There are a number of situations which you cannot resolv e by using TSPITR.
In this situation, you must recover the entire database to a point in time before the tablespace was renamed. The tablespace will be found under the name it had at that earlier time.
VARRAY columns, nested table
s, or external filesSYS, including rollback segmentsTSPITR has some other limitations:
If you do not use a recovery catalog when performing TSPITR, then note the following special restrictions:
CONTROL_FILE_RECORD_KEEP_TIME initi
alization parameter to a value large enough to ensure that control file records needed for TSPITR are kept.)There are several steps to be carried out in preparing for TSPITR:
It is extreme ly important that you choose the right target time or SCN for your TSPITR. As noted already, once you bring a tablespace online after TSPITR, you cannot use any backup from a time earlier than the moment you brought the tablespace online. In practice, this means tha t you cannot make a second attempt at TSPITR if you choose the wrong target time the first time, unless you are using a recovery cata log. (If you have a recovery catalog, however, you can perform repeated TSPITRs to different target times.)
For example, assume that you run TSPITR on a tablespace, and then bring the tablespace online at 5PM on Friday. Back ups of the tablespace created before 5PM Friday are no longer usable for recovery with a current control file. You cannot run TSPITR again on this tablespace with a target time earlier than 5PM Friday, nor can you use the current control file to recover the database to any time earlier than 5PM Friday. Your only option will be point-in-time recovery of your entire database using a restored contro l file.
To investigate past states of your data to identify the target time for TSPITR, you can use features of Oracle such as Oracle Flashback Query, Oracle Transaction Query and Oracle Flashback Version Query to find the p oint in time when unwanted database changes occurred. See "Oracle Flashback Query: Recovering at the R ow Level" for more details on Flashback Query, and Oracle Database Application Developer's Guide - Fundamentals for more information on Flashback Transaction Query and Flashback Version Query.
Your recovery set starts out including the datafiles for the tablespaces you wish to recover. If, however, objects in the tablespaces you need have relationships (such as constraints) to objects in other ta blespaces, you will have to account for this relationship before you can perform TSPITR. You have three choices when faced with such a relationship:
The TS_PITR_CHECK view lets you identify relationsh
ips between objects that span the recovery set boundaries. If this view returns rows when queried, then investigate and correct the p
roblem. Proceed with TSPITR only when TS_PITR_CHECK view returns no rows for the tablespaces not
in the recovery set. Record all actions performed during this step so that you can re-create any suspended or removed relationships
after completing TSPITR.
The following query illustrates how to use the
TS_PITR_CHECK view. For an example with an initial recovery set consisting of tools and users, the <
code>SELECT statement against TS_PITR_CHECK would be as follows:
SELECT * FROM SYS.TS_PITR_CHECK WHERE ( TS1_NAME IN ('USERS','T OOLS') AND TS2_NAME NOT IN ('USERS','TOOLS') ) OR ( TS1_NAME NOT IN ('USERS','TOOLS') AND TS2_NAME IN ('USERS','TOOLS') < a name="1009509"> );
To run a complete TSPITR check on a ll the tablespaces in the database (not just the tablespaces in the recovery set), you can run the following query:
SELECT * FROM SYS.TS_PITR_CHECK WHERE ( 'SYSTEM' IN (TS1_NAME, TS2_NAME) AND TS1_NAME <> TS2_NAME AND TS2_NAME <> '-1' ) OR ( TS1_NAME <&g t; 'SYSTEM' AND TS2_NAME = '-1' );
Because of the number and width of the columns in the TS_PITR_CHECK view, you may want to
format the columns as follows when running the query:
SET LINESIZE 120 a>COLUMN OBJ1_OWNER HEADING "own1" COLUMN OBJ1_OWNER FORMAT a6 COLUMN OBJ1_NAME HEADING " name1" COLUMN OBJ1_NAME FORMAT a5 COLUMN OBJ1_SUBNAME HEADING "subname1" COLUMN OBJ1_SUBNAME FORMAT a8 COLUMN OBJ1_TYPE HEADING "obj1type" COLUMN OBJ1_TYPE FORMAT a8 word_wrapped COLUMN TS1_NAME HEADING "ts1_name" COLUMN TS1_NAME FORMAT a6 COLUMN OBJ2_NAME HEADING "name2" COLUMN OBJ2_NAME FORMAT a5 COLUMN OBJ2_ SUBNAME HEADING "subname2" COLUMN OBJ2_SUBNAME FORMAT a8 COLUMN OBJ2_TYPE HEADING "obj2ty pe" COLUMN OBJ2_TYPE FORMAT a8 word_wrapped COLUMN OBJ2_OWNER HEADING "own2" COLUMN OBJ2_OWNER FORMAT a6 COLUMN TS2_NAME HEADING "ts2_name" COLUMN TS2_NAME FORMAT a6 COLUMN CONSTRAINT_NAME HEADING "cname" COLUMN CONSTRAINT_NAME FORMAT a5 COLUMN REASON HEADING "reason" COLUMN REASON FORMAT a25 word_wrappedAssume a case in which the partitioned table
tphas two partitions,p1 andp2, that exist in tablespacesusersandtoolsrespectively. Also assume that a partit ioned index calledtpindis defined ontp, and that the index has two partitionsid1andid2(that exist in tablespacesid1andid2respectively). In this case, you would get the following output whenTS_PITR_CHECKis queried against tablespacesusersandtools(assuming appropriat e formatting):own1 name1 subname1 obj1type ts1_name name2 subname2 obj2type own2 ts2_name cname reason --- ---- ----- ------ ------- ---- ------ -------- --- -------- -- - ------ SYSTEM TP P1 TABLE USER TPIND IP1 INDEX PARTITION PARTITION SYS ID1 Part itioned Objects not fully contained in the recovery set SYSTEM TP P2 TABLE TOOLS TPIND IP2 INDEX PARTITION PARTITION SYS ID2 Partitioned Objects not fully contained in the recovery setThe table
SYSTEM.tphas a partitioned indextpindthat consists of tw o partitions,ip1in tablespaceid1andip2in tablespaceid2. To perform TSPITR, you must either droptpindor includeid1andid2in the recovery set.
See Also: Oracle Database Reference for more information about the
TS_PITR_CHECKviewIdentifying and Preserving Objects That Will Be Lost After TSPI TR
When RMAN TSPITR is performed on a tablespace, any objects create d after the target recovery time are lost. You can preserve such objects, once they are identified, by exporting them before TSPITR u sing an Oracle export utility (Data Pump Export or Original Export) and re-importing them afterwards using the corresponding import u tility.
To see which objects will be lost in TSPITR, query the
TS_PITR_OBJECTS_TO_BE_ DROPPEDview on the primary database. The contents of the view are described in Table 10-1 .Table 10-1 TS_PITR_OBJECTS_TO_BE_DROPPED View
Filter the view for objects whose CREATION_TIME is after the ta
rget time for TSPITR. For example, with a recovery set consisting of users and tools, and a recovery point
in time of November 2, 2002, 7:03:11 AM, issue the following statement:
SELECT OWNER, NAME, TABLESPACE_NAME, TO_CHAR(CREATION_TIME, 'YYYY-MM-DD:HH24:MI:SS') FROM TS _PITR_OBJECTS_TO_BE_DROPPED WHERE TABLESPACE_NAME IN ('USERS','TOOLS') AND CREATION_TIM E > TO_DATE('02-NOV-02:07:03:11','YY-MON-DD:HH24:MI:SS') ORDER BY TABLESPACE_NAME, CREATION_TIME;
(The TO_CHAR and TO_DATE functions are used to avo
id issues with different national date formats. You can, of course, use local date formats in your own work.)
| See Also:
Oracle Database Reference for more
information about the |
Having selected your tablespaces to recover and your target time, you are now ready to perform RMAN TSPITR. You have a few different options available to you:
When performing fully automated TSPITR, letti ng RMAN manage the entire process, there are only two requirements beyond the preparations in "Plannin g and Preparing for TSPITR":
RMAN bases as much of the configuration for TSPITR as possible on your target database. Duri ng TSPITR, the recovery set datafiles are written in their current locations on the target database. The same channel configurations in effect on the target database are used on the auxiliary instance when restoring files from backup. Auxiliary set datafiles and oth er auxiliary instance files, however, are stored in the auxiliary destination.
Oracle Corporation recommends that you use an auxiliary destination with your auxiliary instance. Ev
en if you use other methods to rename some or all of the auxiliary set datafiles, specifying an AUXILIARY DESTINATION pa
rameter provides a default location for auxiliary set datafiles for which names are not specified. This way, TSPITR will not fail if
you inadvertently do not provide names for all auxiliary set datafiles.
To specify an auxil
iary destination, find a location on disk where there is enough space to hold your auxiliary set datafiles. Then, use the AUXIL
IARY DESTINATION parameter in your RECOVER TABLESPACE command to specify the auxiliary destination l
ocation, as shown in the next section.
To actually peform automated RMAN TSPITR, start the RMAN client, connecting to the target database and, if applicable, a recovery ca talog. This example shows connecting in NOCATALOG mode, using operating system authentication:
% rman TARGET /
If you have configured channels that RMAN can use to restore from backup on the primary instance, then you are ready to p
erform TSPITR now, by running the RECOVER TABLESPACE... UNTIL... command.
This
example returns the users and tools tablespaces to the end of log sequence number 1300, and stores the auxiliary instance files (inc
luding auxiliary set datafiles) in the destination /disk1/auxdest:
RMAN> RE COVER TABLESPACE users, tools UNTIL LOGSEQ 1300 THREAD 1 AUXILIARY DESTINATIO N '/disk1/auxdest';
Assuming the TSPITR process completes without error, the tablespaces are taken offline by RMAN, restored from backup and recovered to the desired point in time on the auxiliary i nstance, and then re-imported to the target database. The tablespaces are left offline at the end of the process. All auxiliary set d atafiles and other auxiliary instance files are cleaned up from the auxiliary destination.
If TSPITR completes successfully, you must back up the recovered tablespaces, and then you can bring them online.
It is very important that you backup recovered tablespaces immediately after TSPITR is completed.
After you perform TSPITR on a tablespace, you cannot use backups of that tablespace from before the TSPITR was completed and the tablespace put back on line. If you start using the recovered tablespaces without taking a backup, you are running your datab ase without a usable backup of those tablespaces. For this example, the users and tools tablespaces must be backed up, as follows:
RMAN> BACKUP TABLESPACE users, tools;
You can then safely bring the tablespaces online, as follows:
RMAN> SQL "ALTER TABLESPACE users, tools ONLINE";
Your recovered tablespace s are now ready for use.
In the event of an error during automated TSPITR, you should refer to "Troubleshooting RMAN TSPITR". The auxiliary set datafiles and other auxiliary instance files will be left in place in the auxililary destinat ion as an aid to troubleshooting. The state of the recovery set files is determined by the type of failure. Once you resolve the prob lem, you can try your TSPITR operation again.
There are several aspects of RMAN TSPITR which you can customize while still mostly follow ing the basic procedure described in "Fully Automated RMAN TSPITR"< /a>:
You may not want the recovery set datafiles restored and recovered in the
ir original locations. The SET NEWNAME command, used in a RUN block, lets you specify a new destination for the restore
from backup and recovery of a datafile.
|
Note< /strong>:
|
Create a RUN block and use SET NEWNAME commands within it to specify new recovery set filenames, as shown here
:
RUN { ... SET NEWNAME FOR DATAFILE 'ORACLE_HOME/oradata/trgt/users01.dbf' TO '/newfs/users01.dbf'; < em class="Italic">...other setup commands... RECOVER TABLESPACE users, tools UNTIL SEQUENCE 1300 THREAD 1; }
RMAN restores the specified datafile from backup to the new location during TSPITR and recovers it in the new location, and updates the control file so that the newly rec overed datafile replaces the old one in the control file. Any existing image copy backup of a datafile found at the new specified loc ation is overwritten.
If the name specified with SET NEWNAME conflicts with th
e name of a valid datafile in the target database, then RMAN reports an error while executing the RECOVER command. The v
alid datafile is not overwritten.
Note that RMAN does not detect conflicts between names se
t with SET NEWNAME and current datafile names on the target database until the actual RECOVER TABLESPACE... UNTIL<
/code> operation. At that point, the conflict is detected, TSPITR fails and RMAN reports an error. If you rename your recovery set da
tafiles, be sure to assign them names that do not conflict with each other, or with the names of your current datafiles.
Unlike the recovery set datafiles, which can be a nd usually are stored in their original locations, the auxiliary set datafiles must not overwrite the corresponding original files in the target database. If you do not specify a location for an auxiliary set file that is different from its original location, then T SPITR will fail when RMAN attempts to overwrite the corresponding file in the original database and discover that the file is in use.
The simplest way to provide locations for your auxiliary set datafiles is to specify an au
xiliary destination for TSPITR. However, RMAN supports two other methods of controlling the location of your auxiliary set datafiles:
specifying new names for individual files with SET NEWNAME, and using DB_FILE_NAME_CONVERT to provide rule
s for converting datafile names in the target database to datafile names for the auxiliary database.
Even if you intend to use either of these methods to provide locations for specific files, it is still suggested that you p
rovide an AUXILIARY DESTINATION argument to RECOVER TABLESPACE. This will ensure that, if you overlook rena
ming some auxiliary set datafiles, your TSPITR will still succeed. Any files not otherwise renamed will be placed in the auxiliary de
stination.
To use th
e SET NEWNAME command to specify a new name for an auxiliary set datafile, enclose your RECOVER TABLESPACE command in a
RUN block, and use a SET NEWNAME command within the RUN block to rename the file. For example:
RMAN> RUN { SET NEWNAME FOR DATAFILE '?/oradata/prod/system01.f' TO '/disk1/auxdest/system01.f' RECOVER TABLESPACE users, tools UNTIL LOGSEQ 1300 THREAD 1 AUXILIARY DESTINATION '/disk1/auxdest'; }
The resulting behavior depends upon whether there is a file at /disk
1/auxdest/system01.f when the RECOVER TABLESPACE command is executed. If there is an image copy backup of the fil
e ?/oradata/system01.f at the specified location, created at an SCN prior to the target time for TSPITR, then the behavi
or is as described in "SET NEWNAME and CONFIGURE AUXNAME With Auxiliary Set Image Copies". Otherwise, the auxiliary set datafile will be restored to the NEWNAME specified instead of the default lo
cation. If your intention is only to control where the auxiliary set datafiles are stored, you should make sure that there is no file
stored at the location specified by SET NEWNAME before performing your TSPITR.
If you do not want to use an auxiliary destination for all
of your auxiliary set datafiles, but you also do not want to name every file individually, you can include a DB_FILE_NAME_CONV
ERT initialization parameter in the initialization parameter file used by your auxiliary instance. You can only use this metho
d in two circumstances:
Refer to the appropriate discussion for your circumstance, to see how to add a parameter to your initialization parameter file. p>
The DB_FILE_NAME_CONVERT parameter in the auxiliary instance specifies how to d
erive names for files in the auxiliary instance from the original names of the corresponding files in the target instance.
For example, assume that the target instance contains the following files:
?/oradata/trgt/system01.dbf of the SYSTEM tablespace?/oradata/trgt/undotbs01.dbf of the undotbs tablespaceand you need to locate the corresponding files in the auxiliary instance in '/bigtmp<
/code>', then you would add the following line to the auxiliary instance parameter file:
DB _FILE_NAME_CONVERT=('?/oradata/trgt', '/bigtmp')
The most importa
nt thing to remember is that DB_FILE_NAME_CONVERT needs to be present in the auxiliary instance parameter file.
If the auxiliary instance was manually created, add DB_FILE_NAME_CONVERT to the auxili
ary instance parameter file (wherever it resides).
Note that you can still rename individua
l auxiliary set datafiles using SET NEWNAME or CONFIGURE AUXNAME. Also, files that do not match the pattern
s provided in DB_FILE_NAME_CONVERT will not be renamed. You may wish to use the AUXILIARY DESTINATION param
eter of RECOVER TABLESPACE to ensure that all auxiliary set datafiles are sent to some destination. If a file is not ren
amed at all, TSPITR will fail.
The different methods of renaming files follow an order of precedence, as follows:
SET NEWNAMECONFIGURE AUXNAME
DB_FILE_NAME_CONVERTAUXILIARY DESTINATION argument to RECOVER TABLESPACESettings higher on the list override settings lower on the list, in situations where both have been applied (by, for example, r
unning RECOVER TABLESPACE... AUXILIARY DESTINATION on a target database where some auxiliary set datafiles also have aux
names configured with CONFIGURE AUXNAME).
You can specify your own location for the control file of your auxiliary instance, if you use a client-
side initialization parameter file. Set the CONTROL_FILES initialization parameter to specify any location you wish for
the control files.
If you do not explicitly specify a location for the control file, RMAN w
ill locate it in the auxiliary destination if you use the AUXILIARY DESTINATION parameter when performing TSPITR. If you
do not use an AUXILIARY DESTINATION parameter, the auxiliary instance control files are stored in an operating system-s
pecific location. (on Unix, ORACLE_HOME/rdbms/admin/params_auxinit.ora).
No matter where you store your auxiliary instance control file, it is removed at the end of a successful TSPITR oper ation. Because control files are relatively small, it is rare that RMAN will encounter a problem creating an auxiliary control file, but if there is not enough space to create the control file, TSPITR will fail.
If you specify the LOG_FILE_NAME_CONVERT initialization parameter in
your auxiliary instance parameter file, this parameter will determine the online redo log location. Otherwise, if RMAN is using an a
uxiliary destination and managing the auxiliary instance for you, it creates the online redo log in the auxiliary destination.
TSPITR performance can be greatly enhanced by redirecting RMAN to use existing image copies of the recovery s
et and auxiliary set datafiles on disk in TSPITR, rather than restoring them from backup. You can use the CONFIGURE AUXNAME command with image copies of recovery set datafiles or auxiliary set datafiles, or the SET NEWNAME command with imag
e copies of auxiliary set datafiles, to tell RMAN about the possible existence of an image copy of a datafile.
While exact details vary depending on the command used and whether the file is an auxiliary set or recovery set f ile, in general, if a suitable image copy is available in the specified location, then during TSPITR, RMAN uncatalogs the image copy from the RMAN repository of the target instance, and catalogs it in the control file of the auxiliary instance. The auxiliary instanc e then performs point-in-time recovery using the image copy.
Details of using image copies with each type of file are explained in the following sections.
During TSPITR, RMAN looks in the specified AUXNAME location for the datafile,
to see whether the file there is an image copy backup of the datafile, with a checkpoint SCN early enough that it can be recovered to
the target time for TSPITR. If such an image copy is found, it is used in TSPITR. Otherwise, the datafile is restored and recovered
in its original location, and any file in the location specified by the AUXNAME is not changed or deleted.
RMAN> CONFIGURE AUXNAME FOR DATAFILE 'ORACLE_HOME/oradata/trgt/users01.dbf'
TO '/newfs/users1.dbf';
...other RMAN commands, if any...
RM
AN> RECOVER TABLESPACE users, tools UNTIL SEQUENCE 1300 THREAD 1;
CONFIGURE AUXNAME is meant to be used as the basis of a strategy to make TSPITR faster by eliminating restore times.
If you have tablespaces on which you anticipate performing TSPITR, you can maintain a set of image copies of the affected datafiles,
updated periodically to the earliest point to which you expect to perform TSPITR. The expected usage model is:
BACKUP AS COPY DATAFILE n FORMAT auxname"
regularly to maintain the updated image copy, or use an incrementally updated backups strategy as described in Oracle Database Backup and Recovery Basics to kee
p the image copies up to date without performing full backups of the datafilesIn planning for TSPITR with image copies, remember that you may not know know which tablespaces will require image copies in advanc e. As discussed in "Determining the Recovery Set: Analyzing Data Relationships", relationships between the tablespaces you wish to TSPITR and other tablespaces may require that you add tablespaces to your final recovery set, and still other tablespaces may wind up in the auxiliary set. You should configure an AUXNAME for each d atafile that is likely to be required, and update image copies of all datafiles often. However, TSPITR will still work if only a subs et of datafiles are prepared in advance using this strategy. The process will just take longer, and recover recovery set datafiles fo r which there are no image copies in their original locations.
Note thatthe order of preced
ence of naming methods is still respected when you use CONFIGURE AUXNAME to rename a recovery set file. A SET NEWN
AME for a recovery set file will override the effect of the CONFIGURE AUXNAME command for the same f
ile. Behavior in this instance will be as described in "Renaming TSPITR Recovery Set Datafiles with SE
T NEWNAME". SET NEWNAME used with a recovery set file never refers to an image copy file.
As with recover
y set datafiles, CONFIGURE AUXNAME sets a persistent alternative location for an auxiliary set datafile image copy, and
SET NEWNAME sets an alternative location for the duration of a RUN block. However, RMAN handles values for auxiliary set
datafiles differently from recovery set datafiles.
If SET NEWNAME is used to
specify a new location for an auxiliary set datafile, and there is an image copy at that location with an SCN such that it can be use
d in TSPITR, then the image copy will be used. If there is no usable image copy at that location, however, RMAN will restore a usable
copy from backup. (If an image copy is present but the SCN is after the target time for TSPITR, then the datafile is overwritten by
the restored file.)
If CONFIGURE AUXNAME is used to specify a new location for
an auxiliary set datafile, and there is an image copy at that location with an SCN such that it can be used in TSPITR, then the imag
e copy will be used. If there is no usable copy at the specified location, the file is restored to this location from bcakup.
As with all auxiliary set files, the file is deleted after successful TSPITR, or left for use in t roubleshooting if TSPITR fails, regardless of whether it was an image copy created before TSPITR or restored by RMAN from backup duri ng TSPITR.
You have enough disk space to save image copies of your entire database for use in TSPITR. In preparation for the possibility that you need pe rform TSPITR, you perform the following tasks:
CONFIGURE AUXNAME FOR DATAFILE n TO auxname_n;
BACKUP AS COPY DATAFILE n FORMAT auxname_n
Note that if the image copies are all in the sam
e location on disk and named similarly to the original datafiles, it is possible to use FORMAT or DB_FILE_NAME_CON
VERT options of the BACKUP command and use BACKUP AS COPY DATABASE instead of performing individual
backups of every datafile. For example if the configured auxnames are a simple translation of the location 'maindisk' to
'auxdisk', you could use the following backup command:
BACKUP AS COPY DATABA SE DB_FILE_NAME_CONVERT=(maindisk, auxdisk);
You are th en prepared for TSPITR without restoring from backup. If, for example, an erroneous batch job started at November 15 2003, 19:00:00 u pdates incorrectly the tables in the tablespace PARTS. You could use the following command to perform TSPITR on tablespace PARTS:
RECOVER TABLESPACE parts UNTIL TIME 'November 15 2003, 19:00:00';
Because AUXNAMES are configured and refer to datafile copies from an SCN before the TSPITR ta rget time, the auxiliary set and recovery set datafiles are not restored from backup. Instead the datafile copies are directly used i n recovery, eliminating the restore overhead.
Note that at the end of the TSPITR, the table
space PARTS will not be located in the original datafile locations, but in the auxname locations. If only the auxnames for the auxili
ary set should be used (so that the recovery set is left in its original locations), then CONFIGURE AUXNAME
... CLEAR should be used before TSPITR is started. In such a case, though, note that the datafiles will have to be rest
ored.
The automatic auxiliary instance looks for parameters in a file that is operating system dependent (for Unix this location is ?' stands for ORACLE_HOME, and the file is located on the
node running the RMAN client, not necessarily the same node as the one running the database instances) This default parameter file f
or the automatic auxiliary instance is always searched when TSPITR is performed. If the file is not found RMAN does not generate an e
rror.
Another way to specify parameters for the automatic auxiliary instance is to place th
e initializations parameter in a file, and then provide the location of these file with the SET AUXILIARY INSTANCE PARAMETER command before executing TSPITR. (Note that the path specified when using SET AUXILIARY INSTANCE PARAMETER is a pat
h on the system running the RMAN client, not the target or auxiliary instances.)
RMAN defin es the following basic parameters for the automatic auxiliary instance:
DB_NAME - Same as db_name of the target database
DB_UNIQUE_NAME - Generated, based on the DB_NAME, to be uniqueDB_BLOCK_SIZE - Same as the DB_BLOCK_SIZE of the target databaseCOMPATIBLE - Same as the compatible setting of the target databaseAUXILIARY DESTINATION is used, RMAN also defines:
DB_CREATE_FILE_DEST - Set to the auxiliary destinationCONTROL_FILES - Generated filename in the auxiliary destinationWhen an auxiliary destination is specified, RMAN uses these two parameters in creating the auxiliary instance online logs and control files in the auxiliary destination.
If AUXILIARY DESTINATION is n
ot used, then you must use LOG_FILE_NAME_CONVERT in an auxiliary instance parameter file to specify the online log file
names. Otherwise, TSPITR fails when attempting to create the online logs for the automatic instance.
If AUXILIARY DESTINATION is not used and you do not use CONTROL_FILES in an auxiliary instance pa
rameter file, the auxiliary instance will create one controlfile with an operating system-dependent name in an operating system depen
dent location. (In Unix, it defaults to ?/dbs/cntrl_@.dbf, where '?' stands for ORACLE_HOME an
d '@' stands for ORACLE_SID. For an automatic auxiliary instance, ORACLE_SID is randomly gener
ated by RMAN).
It is rarely necessary, however, to alter the parameter file, especially if
you provide an AUXILIARY DESTINATION argument to RECOVER TABLESPACE. If one of the six basic initialization
parameters is overridden in the auxiliary instance parameter file, it might cause TSPITR to fail. However, other parameters besides
these basic parameters can be added if needed. For example you can use DB_FILE_NAME_CONVERT to specify the names of the
datafiles in the auxiliary set.
Oracle Corporation recommends that you allow RMAN to manage the creation and destruction of the auxiliary instance used d
uring RMAN TSPITR. However, creating and using your own auxiliary instance is also supported. One reason you might want to do this is
to exercise control of channels used in TSPITR. RMAN's automatic auxiliary instance uses the configured channels of the target datab
ase as the basis for the channels to configure on the auxiliary instance and use during backup. If you need different channel setting
s, and you do not want to use CONFIGURE to change the settings on the target database, you can operate your own auxiliar
y instance.
Creating an Oracle instance suitable for use as an auxiliary instance requires that you carry out all of the following steps:
For instructions on how to create and maintain Oracle password files, refer to the Oracle Database Admi nistrator's Guide.
Create a client-side initialization parameter file for the auxiliary instance on the machine where you will
be running SQL*Plus to contorl the auxiliary instance. For this example, we will assume your parameter file is placed at /tmp/
initAux.ora. Set the parameters described in the following table, making sure that paths in parameters like DB_FILE_NAME
_CONVERT, LOG_FILE_NAME_CONVERT and CONTROL_FILES are all server-side paths, not client-side.
| Parameter | Mandatory? | Value |
|---|---|---|
|
|
YES |
The same name as the target database. |
|
|
YES |
A value different from any database in the same Oracle home. For simplicity, specify |
|
|
YES |
Patterns to gener
ate filenames for the online redo logs of the auxiliary database based on the online redo log names of the target database. Query This parameter is the only way to name the online redo l ogs for the auxiliary instance. Without it, TSPITR will fail when trying to open the auxiliary instance because the online logs canno t be created. Note: Some platforms do not support ending patte
rns in a forward or backward slash ( |
|
YES |
Set to | |
|
|
YES |
The same value as th e parameter in the target database. |
|
|
YES |
If this initialization parameter is set in the target database, then it must be set to the same value in the auxiliary instance. |
|
|
NO< /p> |
Patterns to convert filenames for the datafiles of the auxiliary da
tabase. You can use this parameter to generate filenames for those files that you did not name with Note: Some platforms do no
t support ending patterns in a forward or backward slash ( See Also: "Using DB_FILE_NAME_CONVERT to Name Auxiliary Set Datafiles"< /a> |
|
|
NO |
Filenames that do not conflict with the control file names of the target instance (or any other existing file). |
Set other parameters as
needed, including the parameters that allow you to connect as SYSDBA through Oracle Net.
Following are examples of the initialization parameter settings for the auxiliary instance:
DB_NAME=trgt
DB_UNIQUE_NAME=_trgt
CONTROL_FILES=/tmp/control01.ctl
DB_FILE_NAME_CONVERT=('/oracle/oradata/trgt/','/tmp/')
LOG_FILE_NAME_CONVERT=('/oracle/oradata/trg
t/redo','/tmp/redo')
REMOTE_LOGIN_PASSWORDFILE=exclusive
COMPATIBLE =10.1.0
DB_BLOCK_SIZE=8192
|
Note: After setting these initialization parameters, ensure that you do not overwrite the initialization settings for the production files at the target database. |
| See Also:
Oracle Net Services Administrator's Guide for more information about Oracle Net |
The auxiliary instance must have a valid net service name. Before proceeding, use SQ L*Plus to ensure that you can establish a connection to the auxiliary instance.
If you are running your own auxiliary instance, then you may f
ind that the sequence of commands required for TSPITR is quite long, if you allocate a complex channel configuration for restoring fr
om backup, or if you are not using DB_FILE_NAME_CONVERT to control file naming.
You may wish to store the sequence of commands for TSPITR in a command file, a text file under the host operating system. This comm
and file can be read into RMAN using the @ command (or the CMDFILE command line argument when starting RMAN
) to execute the series of commands in the command file.
See "Using RMAN with Command Files" for more details.
When you run your own auxiliary instance, the default beha
vior is to use the automatic channel configuration of the target instance. However, if you decide to allocate your own channel config
uration, you can do so by including the ALLOCATE AUXILIARY CHANNEL commands in a RUN block along with the RECOVER
TABLESPACE command for TSPITR. Plan out these commands, if necessary, and add them to the sequence of commands you will run to
perform your TSPITR.
See the example in "Executing TSPITR W ith Your Own Auxiliary Instance: Scenario" for details of how to include channel allocation in your TSPITR script.
You may wish to use SET NEWNAME commands, either to refer to existing image copies of auxiliary set files
to improve TSPITR performance, or to assign new names to the recovery set files for after TSPITR. Plan out these commands, if necessa
ry, and add them to the sequence of commands you will run to perform your TSPITR.
With the preparations complete and your TSPITR commands completely planned, yo u are now ready to carry out your TSPITR. The following steps are required:
Before beginning RMAN
TSPITR, use SQL*Plus to connect to the auxiliary instance and start it in NOMOUNT mode, specifying a parameter file if n
ecessary. For example:
SQL> CONNECT SYS/oracle@aux AS SYSDBA SQL&g t; STARTUP NOMOUNT PFILE='/tmp/initAux.ora'
Remember that the pat h for the PFILE will be a client-side path, on the machine from which you run SQL*Plus, not a server-side path.
Because the auxiliary instance does not yet have a control file, you can only start the instance in NOMOUN
T mode. Do not create a control file or try to mount or open the auxiliary instance for TSPITR.
Start RMAN connecting to the target and t he manually created auxiliary instance:
% rman target / auxiliary sysuse r/syspwd@auxiliary_service_name
Now you are ready to run your TSPITR commands. In the simplest case, just
execute the RECOVER TABLESPACE... UNTIL command at the RMAN prompt:
RMAN> R ECOVER TABLESPACE ts1, ts2... UNTIL TIME 'time'
If you want to use ALLOCATE CHANNEL or SET NEWNAME then create a RUN block w
hich includes those commands before the RECOVER TABLESPACE command.
RUN {
ALLOCATE CHANNEL c1 DEVICE TYPE DISK;
ALLOCATE CHANNEL c2 DEVICE TYPE SBT;
#
and so on...
RECOVER TABLESPACE ts1, ts2 UNTIL TIME 'time';
}
Entering a lengthy
series of commands in a RUN block can be error-prone. To avoid making mistakes entering the sequence of commands, create a command f
ile (called, for example, /tmp/tspitr.rman) to store the whole sequence of commands for your TSPITR. Review it carefully
to catch any errors. Then run the command file at the RMAN prompt, using this command:
RMA N> @/tmp/tspitr.rman ;
The results will be the same as in the previous example.
The following example shows the execution of a RECOVER TABLESPACE... UNTIL operation using the following features of RM
AN TSPITR:
SET NEWNAMESET NEWNAMEThe process used is as follows:
tspitr" as the password for the auxiliary instan
ce in the password file, and set up the auxiliary instance parameter file /bigtmp/init_tspitr_prod.ora with the followin
g settings:
db_name=PROD db_unique_name=tspitr_PROD < /a>control_files=/bigtmp/tspitr_cntrl.f' db_file_name_convert=('?/oradata/prod', '/bigtmp') < /a>log_file_name_convert=('?/oradata/prod', '/bigtmp') compatible=10.1.0 block_size=8192 remote_login_password=exclusive
pitprod for the auxiliary instance, and check for connectivity.$ sqlplus SQL> connect sys/tspitr@pit_prod as sysdba SQL> startup nomount pfi le=/bigtmp/init_tspitr_prod.ora
% rman target / auxiliary sys/tspitr@pit_prod < a name="1032847">
run { # Specify NEWNAMES for rec overy set datafiles SET NEWNAME FOR DATAFILE '?/oradata/prod/clients01.f' TO '?/oradata/prod/clients01_rec.f'; SET NEWNAME FOR DATAFILE '?/oradata/pr od/clients02.f' TO '?/oradata/prod/clients02_rec.f'; SET NEWNAME FOR DATAFILE '?/oradata/prod/clients03.f' TO '?/oradata /prod/clients03_rec.f'; SET NEWNAME FOR DATAFILE '?/oradata/prod/clients04.f' TO '?/oradata/prod/clients04_rec.f'; # Specified newn ames for some of the auxiliary set # datafiles that have a valid image copy to avoid restores: SET NEWNAME FOR DATAFILE '?/oradata/prod/system01.f' TO '/ backups/prod/system01_monday_noon.f'; SET NEWNAME FOR DATAFILE '?/oradata/prod/system02.f' TO '/backups/prod/system02_monday_noon.f'; SET NEWN AME FOR DATAFILE '?/oradata/prod/undo01.f' TO '/backups/prod/undo01_monday_no on.f'; # Specified the disk and SBT channels to use al locate auxiliary channel c1 device type disk; allocate auxiliary channel c2 device type disk; allocate auxiliary channel t1 device type sbt; allocate auxiliary chan nel t2 device type sbt; # Recovered the clients tablespace to 24 hours ago: RECOVER TABLESPACE clients UNTIL TIME 'sysdate-1'; }
If the TSPITR operation is successful, then the results are:
If the TSPITR operation fails, the auxiliary files are left on disk for troubleshooting purposes. If RMAN creat ed the auxiliary instance, it is shut down; otherwise it is left in whatever state it was in when the TSPITR operation failed.
A variety of problems can cause TSPITR to fail before t he process is complete.
SET NEWNAME or CONFIGURE AUXNAME commands, an
d filenames generated by the effect of the DB_FILE_NAME_CONVERT parameter.If your uses of SET NEWNAME, CONFIGURE AUXNAME and DB_FILE_NAME_CONVERT cause multiple f
iles in the auxiliary or recovery sets to have the same name, RMAN will report an error during TSPITR. To correct the problem, use di
fferent values for these parameters to eliminate the duplicate name.
In this case, you need to edit the recover.bsq file, where
ver it resides on your host platform. For instance, on UNIX, it is located in $ORACLE_HOME/rdbms/admin. This file contai
ns the following:
# # tspitr_7: do the incomplete recovery and reset logs. This member is used once. # define tspitr_7 <<< # make the control file point at the restored datafiles, then recover them RECOVER CLON E DATABASE TABLESPACE &1&; 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"; } >>>
Remove the '#' symbols from the last two lines of comments and m odify the statement to create a temporary tablespace. Retry the TSPITR operation, increasing the size of the tablespace until the exp ort operation succeeds.
If you are managing your own auxiliary instance and there is a failure in TSPITR, then before you can try TSPIT R again, you must shut down the auxiliary instance, correct the problem which interfered with TSPITR, and then bring the auxiliary in stance back to NOMOUNT before trying TSPITR again.