For each data file on the destination host that is restored to a different path than it had on the source host, use a SET NEWNAME command to specify the new path on the destination host. If the file systems on the destination system are set up to have the same paths as the source host, then do not use SET NEWNAME for those files restored to the same path as on the source host. B错误
For each online redo log that is to be created at a different location than it had on the source host, use SQL ALTER DATABASE RENAME FILEcommands to specify the path name on the destination host. If the file systems on the destination system are set up to have the same paths as the source host, then do not use ALTER DATABASE RENAME FILE for those files restored to the same path as on the source host.
Perform a SET UNTIL operation to limit recovery to the end of the archived redo logs. The recovery stops with an error if no SET UNTIL command is specified.
Restore and recover the database.
Run the SWITCH DATAFILE ALL command so that the control file recognizes the new path names as the official new names of the data files.
Example 20-3 shows the RMAN script reco_test.rman that can perform the restore and recovery operation.
Example 20-3 Restoring a Database on a New Host
RUN { # allocate a channel to the tape device ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS '...'; # rename the data files and online redo logs 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/cwmlite01.dbf'; SET NEWNAME FOR DATAFILE 4 TO ' /oradata/test/drsys01.dbf'; SET NEWNAME FOR DATAFILE 5 TO ' /oradata/test/example01.dbf'; SET NEWNAME FOR DATAFILE 6 TO ' /oradata/test/indx01.dbf'; SET NEWNAME FOR DATAFILE 7 TO ' /oradata/test/tools01.dbf'; SET NEWNAME FOR DATAFILE 8 TO ' /oradata/test/users01.dbf'; SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo01.log'' TO '' /oradata/test/redo01.log'' "; SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo02.log'' TO '' /oradata/test/redo02.log'' "; # Do a SET UNTIL to prevent recovery of the online logs SET UNTIL SCN 123456; # restore the database and switch the data file names RESTORE DATABASE; SWITCH DATAFILE ALL; # recover the database RECOVER DATABASE; } EXITExecute the script created in the previous step.
For example, start RMAN to connect to the target database and run the @ command:
% rman TARGET / NOCATALOG RMAN> @reco_test.rmanOpen the restored database with the RESETLOGS option.
From the RMAN prompt, open the database with the RESETLOGS option:
ALTER DATABASE OPEN RESETLOGS;Caution:
When you re-open your database in the next step, do not connect to the recovery catalog. Otherwise, the new database incarnation created is registered automatically in the recovery catalog, and the file names of the production database are replaced by the new file names specified in the script.Optionally, delete the test database with all of its files.
Note:
If you used an ASM disk group, then the DROP DATABASE command is the only way to safely remove the files of the test database. If you restored to non-ASM storage then you can also use operating system commands to remove the database.Use the DROP DATABASE command to delete all files associated with the database automatically. The following example deletes the database files:
STARTUP FORCE NOMOUNT PFILE=' /oradata/test/inittrgta.ora'; DROP DATABASE;Because you did not perform the restore and recover