Oracle® Database Backup and Recovery Advanced User's Guide 10g Release 1 (10.1) Part Number B10734-01 |
|
|
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 the 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 order 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
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 instance has other files associated with it, such as a control file, parameter file, and online logs , but they are not part of the auxiliary 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 auxiliary 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 points 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 contents 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 situations such as these:
TRUNCATE
TABLE
statement;Note that, as with database point-in-time recovery (DBPITR), you cannot perform TSPITR if you do not have your archived redo logs. For databases running in NOARCHIVELOG mode, you cannot perform TSPITR.
There are a number of situations which you cannot resolve 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 tables, 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
initialization 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 extremely 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 that you cannot make a second attempt at TSPITR if you choose the wrong target time the first time, unless you are using a recovery catalog. (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. Backups 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 control 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 point in time when unwanted database changes occurred. See "Oracle Flashback Query: Recovering at the Row 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 tablespaces, 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 relationships between objects that span the recovery set boundaries. If this view returns rows when queried, then investigate and correct the problem. 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 SELECT
statement against TS_PITR_CHECK
would be as follows:
SELECT * FROM SYS.TS_PITR_CHECK WHERE ( TS1_NAME IN ('USERS','TOOLS') AND TS2_NAME NOT IN ('USERS','TOOLS') ) OR ( TS1_NAME NOT IN ('USERS','TOOLS') AND TS2_NAME IN ('USERS','TOOLS') );
To run a complete TSPITR check on all 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 <> '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 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 "obj2type" 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_wrapped
Assume a case in which the partitioned table tp
has two partitions, p1
and p2
, that exist in tablespaces users
and tools
respectively. Also assume that a partitioned index called tpind
is defined on tp
, and that the index has two partitions id1
and id2
(that exist in tablespaces id1
and id2
respectively). In this case, you would get the following output when TS_PITR_CHECK
is queried against tablespaces users
and tools
(assuming appropriate 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 Partitioned 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 set
The table SYSTEM.tp
has a partitioned index tpind
that consists of two partitions, ip1
in tablespace id1
and ip2
in tablespace id2
. To perform TSPITR, you must either drop tpind
or include id1
and id2
in the recovery set.
See Also:
Oracle Database Reference for more information about the |
When RMAN TSPITR is performed on a tablespace, any objects created after the target recovery time are lost. You can preserve such objects, once they are identified, by exporting them before TSPITR using an Oracle export utility (Data Pump Export or Original Export) and re-importing them afterwards using the corresponding import utility.
To see which objects will be lost in TSPITR, query the TS_PITR_OBJECTS_TO_BE_DROPPED
view on the primary database. The contents of the view are described in Table 10-1.
Filter the view for objects whose CREATION_TIME
is after the target 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_TIME > 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 avoid 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, letting RMAN manage the entire process, there are only two requirements beyond the preparations in "Planning and Preparing for TSPITR":
RMAN bases as much of the configuration for TSPITR as possible on your target database. During 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 other auxiliary instance files, however, are stored in the auxiliary destination.
Oracle Corporation recommends that you use an auxiliary destination with your auxiliary instance. Even if you use other methods to rename some or all of the auxiliary set datafiles, specifying an AUXILIARY DESTINATION
parameter 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 auxiliary destination, find a location on disk where there is enough space to hold your auxiliary set datafiles. Then, use the AUXILIARY DESTINATION
parameter in your RECOVER
TABLESPACE
command to specify the auxiliary destination location, 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 catalog. 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 perform 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 (including auxiliary set datafiles) in the destination /disk1/auxdest
:
RMAN> RECOVER TABLESPACE users, tools UNTIL LOGSEQ 1300 THREAD 1 AUXILIARY DESTINATION '/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 instance, and then re-imported to the target database. The tablespaces are left offline at the end of the process. All auxiliary set datafiles 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 database 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 tablespaces 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 destination as an aid to troubleshooting. The state of the recovery set files is determined by the type of failure. Once you resolve the problem, you can try your TSPITR operation again.
There are several aspects of RMAN TSPITR which you can customize while still mostly following the basic procedure described in "Fully Automated RMAN TSPITR":
You may not want the recovery set datafiles restored and recovered in their 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:
|
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'; ...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 recovered datafile replaces the old one in the control file. Any existing image copy backup of a datafile found at the new specified location is overwritten.
If the name specified with SET NEWNAME
conflicts with the name of a valid datafile in the target database, then RMAN reports an error while executing the RECOVER
command. The valid datafile is not overwritten.
Note that RMAN does not detect conflicts between names set with SET NEWNAME
and current datafile names on the target database until the actual RECOVER TABLESPACE... UNTIL
operation. At that point, the conflict is detected, TSPITR fails and RMAN reports an error. If you rename your recovery set datafiles, 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 and 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 TSPITR 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 auxiliary 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 rules 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 provide an AUXILIARY DESTINATION
argument to RECOVER TABLESPACE
. This will ensure that, if you overlook renaming some auxiliary set datafiles, your TSPITR will still succeed. Any files not otherwise renamed will be placed in the auxiliary destination.
To use the 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 /disk1/auxdest/system01.f
when the RECOVER TABLESPACE
command is executed. If there is an image copy backup of the file ?/oradata/system01.f
at the specified location, created at an SCN prior to the target time for TSPITR, then the behavior 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 location. 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_CONVERT
initialization parameter in the initialization parameter file used by your auxiliary instance. You can only use this method in two circumstances:
Refer to the appropriate discussion for your circumstance, to see how to add a parameter to your initialization parameter file.
The DB_FILE_NAME_CONVERT
parameter in the auxiliary instance specifies how to derive 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
', then you would add the following line to the auxiliary instance parameter file:
DB_FILE_NAME_CONVERT=('?/oradata/trgt', '/bigtmp')
The most important 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 auxiliary instance parameter file (wherever it resides).
Note that you can still rename individual auxiliary set datafiles using SET NEWNAME
or CONFIGURE AUXNAME
. Also, files that do not match the patterns provided in DB_FILE_NAME_CONVERT
will not be renamed. You may wish to use the AUXILIARY DESTINATION
parameter of RECOVER TABLESPACE
to ensure that all auxiliary set datafiles are sent to some destination. If a file is not renamed at all, TSPITR will fail.
The different methods of renaming files follow an order of precedence, as follows:
SET NEWNAME
CONFIGURE AUXNAME
DB_FILE_NAME_CONVERT
AUXILIARY DESTINATION
argument to RECOVER TABLESPACE
Settings higher on the list override settings lower on the list, in situations where both have been applied (by, for example, running RECOVER TABLESPACE... AUXILIARY DESTINATION
on a target database where some auxiliary set datafiles also have auxnames 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 will 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-specific 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 operation. 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 auxiliary 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 set 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 image 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 file, 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 instance 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... RMAN> 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 keep 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 advance. 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 datafile that is likely to be required, and update image copies of all datafiles often. However, TSPITR will still work if only a subset of datafiles are prepared in advance using this strategy. The process will just take longer, and recover recovery set datafiles for which there are no image copies in their original locations.
Note thatthe order of precedence of naming methods is still respected when you use CONFIGURE AUXNAME
to rename a recovery set file. A SET NEWNAME
for a recovery set file will override the effect of the CONFIGURE
AUXNAME
command for the same file. Behavior in this instance will be as described in "Renaming TSPITR Recovery Set Datafiles with SET NEWNAME". SET NEWNAME used with a recovery set file never refers to an image copy file.
As with recovery 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 used 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 image 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 troubleshooting if TSPITR fails, regardless of whether it was an image copy created before TSPITR or restored by RMAN from backup during 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 perform 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 same location on disk and named similarly to the original datafiles, it is possible to use FORMAT
or DB_FILE_NAME_CONVERT
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 DATABASE DB_FILE_NAME_CONVERT=(maindisk, auxdisk);
You are then prepared for TSPITR without restoring from backup. If, for example, an erroneous batch job started at November 15 2003, 19:00:00 updates 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 target time, the auxiliary set and recovery set datafiles are not restored from backup. Instead the datafile copies are directly used in recovery, eliminating the restore overhead.
Note that at the end of the TSPITR, the tablespace PARTS will not be located in the original datafile locations, but in the auxname locations. If only the auxnames for the auxiliary 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 restored.
The automatic auxiliary instance looks for parameters in a file that is operating system dependent (for Unix this location is ?/rdbms/admin/params_auxint.ora
, where '?
' 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 for the automatic auxiliary instance is always searched when TSPITR is performed. If the file is not found RMAN does not generate an error.
Another way to specify parameters for the automatic auxiliary instance is to place the 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 path on the system running the RMAN client, not the target or auxiliary instances.)
RMAN defines the following basic parameters for the automatic auxiliary instance:
DB_NAME
- Same as db_name of the target databaseDB_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 databaseIf AUXILIARY
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 not 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 parameter file, the auxiliary instance will create one controlfile with an operating system-dependent name in an operating system dependent location. (In Unix, it defaults to ?/dbs/cntrl_@.dbf
, where '?
' stands for ORACLE_HOME
and '@
' stands for ORACLE_SID
. For an automatic auxiliary instance, ORACLE_SID
is randomly generated 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 during 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 database as the basis for the channels to configure on the auxiliary instance and use during backup. If you need different channel settings, and you do not want to use CONFIGURE
to change the settings on the target database, you can operate your own auxiliary 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 Administrator'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 generate 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 logs for the auxiliary instance. Without it, TSPITR will fail when trying to open the auxiliary instance because the online logs cannot be created. Note: Some platforms do not support ending patterns in a forward or backward slash ( |
|
YES |
Set to |
|
YES |
The same value as the 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 |
Patterns to convert filenames for the datafiles of the auxiliary database. You can use this parameter to generate filenames for those files that you did not name with Note: Some platforms do not support ending patterns in a forward or backward slash ( See Also: "Using DB_FILE_NAME_CONVERT to Name Auxiliary Set Datafiles" |
|
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/trgt/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 SQL*Plus to ensure that you can establish a connection to the auxiliary instance.
If you are running your own auxiliary instance, then you may find that the sequence of commands required for TSPITR is quite long, if you allocate a complex channel configuration for restoring from 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 command 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 behavior is to use the automatic channel configuration of the target instance. However, if you decide to allocate your own channel configuration, 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 With 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 necessary, 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, you 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 necessary. For example:
SQL> CONNECT SYS/oracle@aux AS SYSDBA SQL> STARTUP NOMOUNT PFILE='/tmp/initAux.ora'
Remember that the path 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 NOMOUNT
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 the manually created auxiliary instance:
% rman target / auxiliary sysuser/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> RECOVER TABLESPACE ts1, ts2... UNTIL TIME 'time'
If you want to use ALLOCATE CHANNEL
or SET NEWNAME
then create a RUN block which 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 file (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:
RMAN> @/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 RMAN TSPITR:
SET NEWNAME
SET NEWNAME
The process used is as follows:
tspitr
" as the password for the auxiliary instance in the password file, and set up the auxiliary instance parameter file /bigtmp/init_tspitr_prod.ora
with the following settings:
db_name=PROD db_unique_name=tspitr_PROD control_files=/bigtmp/tspitr_cntrl.f' db_file_name_convert=('?/oradata/prod', '/bigtmp') 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 pfile=/bigtmp/init_tspitr_prod.ora
% rman target / auxiliary sys/tspitr@pit_prod
run { # Specify NEWNAMES for recovery set datafiles SET NEWNAME FOR DATAFILE '?/oradata/prod/clients01.f' TO '?/oradata/prod/clients01_rec.f'; SET NEWNAME FOR DATAFILE '?/oradata/prod/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 newnames 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 NEWNAME FOR DATAFILE '?/oradata/prod/undo01.f' TO '/backups/prod/undo01_monday_noon.f'; # Specified the disk and SBT channels to use allocate auxiliary channel c1 device type disk; allocate auxiliary channel c2 device type disk; allocate auxiliary channel t1 device type sbt; allocate auxiliary channel 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 created 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 the process is complete.
SET NEWNAME
or CONFIGURE AUXNAME
commands, and 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 files in the auxiliary or recovery sets to have the same name, RMAN will report an error during TSPITR. To correct the problem, use different values for these parameters to eliminate the duplicate name.
In this case, you need to edit the recover.bsq
file, wherever it resides on your host platform. For instance, on UNIX, it is located in $ORACLE_HOME/rdbms/admin
. This file contains the following:
# # tspitr_7: do the incomplete recovery and resetlogs. This member is used once. # define tspitr_7 <<< # make the control file point at the restored datafiles, then recover them RECOVER CLONE 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 modify the statement to create a temporary tablespace. Retry the TSPITR operation, increasing the size of the tablespace until the export operation succeeds.
If you are managing your own auxiliary instance and there is a failure in TSPITR, then before you can try TSPITR again, you must shut down the auxiliary instance, correct the problem which interfered with TSPITR, and then bring the auxiliary instance back to NOMOUNT before trying TSPITR again.