Use the
procedure described below to perform test restores. You can
also use it to move a production database to a new host.
The
database identifier (DBID) for the restored test database is the same as the
DBID of the original database. If you are using a recovery catalog and connect
to the test database and the recovery catalog database, the recovery catalog is
updated with information about the test database. This can impact RMAN’s
ability to restore and recover the source database.
You should
create a duplicate database using the RMAN DUPLICATE command if your goal is to
create a new copy of your target database for ongoing use on a new host. The
duplicate database is assigned a new DBID that allows it to be registered in
the same recovery catalog as the original target database.
To prepare
to restore a database, perform the following steps:
•
Record
the database identifier (DBID) of your source database.
•
Copy
the source database initialization parameter file to the new host.
•
Ensure
that source backups, including the control file autobackup, are accessible on
the restore host.
Preparing
to Restore the Database to a New Host
Perform the
steps listed above to prepare for the restore of the database to a new host.
Note: If you are performing a test
restore, do not connect to the recovery catalog when restoring the data files.
If you connect to the recovery catalog, RMAN records information about the
restored data files in the recovery catalog and considers the restored database
as the current target database. If your control file is not large enough to
contain all of the RMAN repository data on the backups you need to restore and
you must use a recovery catalog, then export the catalog and import it into a
different schema or database. Use the copied recovery catalog for the test
restore.
Restoring
the Database to a New Host
Perform the
steps listed on this page and the next on the restore host to restore the
database.
1. Configure the ORACLE_SID environment
variable as shown in the following example:
$ setenv ORACLE_SID orcl
2. Start RMAN and connect to the target
instance. Do not connect to the recovery catalog as shown in the following
example:
$ rman TARGET /
3. Set the database identifier (DBID). You
can find the DBID of your source database by querying the DBID column in
V$DATABASE.
RMAN> SET DBID
1090776545;
4. Start the instance in NOMOUNT mode:
RMAN> STARTUP NOMOUNT
You will
receive an error similar to the following because the server parameter file has
not been restored. RMAN uses a “dummy” parameter file to start the instance.
startup failed: ORA-01078:
failure in processing system parameters
5. Restore the server parameter file from
the backup sets and shut down the instance as shown in the example:
RESTORE SPFILE TO PFILE
'?/oradata/test/initorcl.ora' FROM AUTOBACKUP;
6.
Shut
down the instance:
SHUTDOWN IMMEDIATE;
7. Edit the restored initialization
parameter file to change any location-specific parameters, such as those ending
in _DEST, to reflect the new directory structure.
8. Start the instance in NOMOUNT mode using
your edited text initialization parameter file.
RMAN> STARTUP NOMOUNT
PFILE='/oradata/test/initorcl.ora';
9. Create a RUN block to restore the control
file from an autobackup and mount the database as shown in the example:
RUN
{
RESTORE CONTROLFILE FROM
AUTOBACKUP;
ALTER DATABASE MOUNT;
}
10.Query
V$DATAFILE to determine the file names of the database on your new host. Create
the RMAN recovery script to restore and recover the database. Use the SET
NEWNAME command to specify the path on your new host for each of the data
files. Use the SQL ALTER DATABASE RENAME FILE command to specify the path for
the online redo log files. Include the SET UNTIL command to limit recovery to
the end of the archived redo log files. Include the SWITCH command so that the
control file recognizes the new path names as the correct names for the data
files. An example of a recovery script follows:
RUN
{
SET NEWNAME FOR DATAFILE 1
TO '?/oradata/test/system01.dbf';
SET NEWNAME FOR DATAFILE 2
TO '?/oradata/test/undotbs01.dbf';
SET NEWNAME FOR DATAFILE 3
TO '?/oradata/test/sysaux.dbf';
SET NEWNAME FOR DATAFILE 4
TO '?/oradata/test/users01.dbf';
SET NEWNAME FOR DATAFILE 5
TO '?/oradata/test/example01.dbf';
SQL "ALTER DATABASE
RENAME FILE ''/u01/app/oracle/oradata/orcl/redo01.log''
TO
''?/oradata/test/redo01.log'' ";
SQL "ALTER DATABASE
RENAME FILE ''/u01/app/oracle/oradata/orcl/redo02.log''
TO
''?/oradata/test/redo02.log'' ";
SQL "ALTER DATABASE
RENAME FILE ''/u01/app/oracle/oradata/orcl/redo03.log''
TO
''?/oradata/test/redo03.log'' ";
SET UNTIL SCN 4545727;
RESTORE DATABASE;
SWITCH DATAFILE ALL;
RECOVER DATABASE;
}
11. Execute the recovery script.
12. Open the database with the RESETLOGS
option:
RMAN> ALTER DATABASE
OPEN RESETLOGS;