首页 > Linux操作系统 > Linux操作系统 > RMAN Restore
To restore files from backups or image copies. By default, RMAN restores files to their default location. You can use the SET NEWNAME command to restore files to nondefault locations. RMAN restores backups from disk or tape and restores images copies from disk only.
Typically, you restore when a media failure has damaged a current datafile, control file, or archived log or prior to performing a point-in-time recovery. The RESTORE command restores full backups, incremental backups (level 0 only), or copies of datafiles, control files, and archived redo logs. Because the RECOVER command automatically restores archived logs as needed, you should seldom need to restore logs manually. Possible reasons for manually restoring archived logs are to speed up recovery or to stage the logs to multiple destinations.
Note: In Oracle9i, unlike in previous RMAN releases, RMAN by default does not restore a datafile if the file is in the correct place and its header contains the expected data (RMAN does not scan the datafile body for corrupt blocks). The FORCE option overrides this behavior and restores the requested files unconditionally. |
When you run RESTORE in CATALOG mode with a backup control file, RMAN automatically adjusts the control file to reflect the structure of the restored database.
If you restore to the default location, then RMAN overwrites files with the same filenames. If you restore to a new location, then issue SET NEWNAME commands to rename the files and issue a SWITCH command to make the restored files current. If you do not issue SWITCH commands, then RMAN considers the restored files as valid copies for use in future restore operations.
If you do not manually allocate channels, then RMAN allocates all automatic channels possibly needed by the RESTORE command. For example, assume you configure 3 separate sbtchannels (each with different PARMS) and then configure parallelism for DISK and sbt as follows:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2; CONFIGURE DEVICE TYPE sbt PARALLELISM 3; CONFIGURE DEFAULT DEVICE TYPE TO sbt;
During a restore, RMAN allocates three sbt channels and the two preconfigured DISK channels. For a restore, RMAN allocates all configured channels unless the DEVICE TYPE option restricts the device type from which RMAN restores files.
In a Real Application Clusters configuration, RMAN automatically restores backups, control file copies, and datafile copies from channels that can read the files on tape or a local file system. For example, if channel 1 connected to instance 1 can read log 1000 from its tape drive, but channel 2 connected to instance 2 cannot read the log from its tape drive, then channel 1 restores the log. Autolocation is automatically enabled when the channels meet any of the following criteria:
| See Also: Oracle9i Recovery Manager User's Guide to learn how to restore files |
Note: When performing a database validation by using RESTORE ... VALIDATE, the database can be open. |
For example, if you made some backups of a datafile to DISK channels and others to sbt channels, and only a DISK channel is allocated for the RESTORE command, RMAN will not restore backups that were created on sbt channels.
RESTORE TABLESPACE SYSTEM DATAFILE 1;
Table 2-25 indicates the restrictions that apply in different situations involving the RESTORE CONTROLFILE command.
Table 2-25 RESTORE CONTROLFILE Scenarios| RESTORE CONTROLFILE; | RESTORE CONTROLFILE FROM AUTOBACKUP; | RESTORE CONTROLFILE ... TO 'filename'; | RESTORE CONTROLFILE ... FROM 'media_handle' or TAG; | |
|---|---|---|---|---|
No catalog, target started | Error. Must specify FROMAUTOBACKUP. | First run SET DBID. Restores toCONTROL_FILES locations. | First run SET DBID. Must specifyFROM AUTOBACKUP. Restores only to filename. | First run SET DBID. Restores from specified file (cannot restore from TAG). If TO 'filename' not used, restores to allCONTROL_FILES locations. |
No catalog, target mounted or open | Error. Must use TO 'filename', where filename is not inCONTROL_FILES list. | Error. Must use TO 'filename', where filename is not inCONTROL_FILES list. | Restores only to filename, wherefilename is not inCONTROL_FILES list. | Restores from specified file. If TO 'filename' not used, restores to all CONTROL_FILES locations. |
Catalog, target started | Restores to CONTROL_FILESlocations. Run SET DBID only if | Do not use with catalog unless for testing purposes. | Restores only to filename, wherefilename is not inCONTROL_FILES list. | Restores from specified file. If TO 'filename' not used, restores to all CONTROL_FILES locations. |
Catalog, target mounted or open | Error. Must use TO 'filename', where filename is not inCONTROL_FILES list. | Do not use with catalog. | Restores only to filename, wherefilename is not inCONTROL_FILES list. | Restores from specified file. If TO 'filename' not used, restores to all CONTROL_FILES locations. |
This example takes a tablespace offline, restores it, then performs media recovery:
SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE"; RESTORE TABLESPACE users; RECOVER TABLESPACE users; SQL "ALTER TABLESPACE users ONLINE";Restoring the Control File When Using a Recovery Catalog: Example
This example restores the control file to its default location, replicates it automatically to all CONTROL_FILES locations, and mounts the database:
RUN
{ # SET DBID is not necessary when connected to a recovery catalog
STARTUP FORCE NOMOUNT;
RESTORE CONTROLFILE;
ALTER DATABASE MOUNT;
}
Restoring the Control File with a Tag: ExampleThis NOCATALOG example restores the control file specified by a tag, and then mounts the database:
CONNECT TARGET / STARTUP NOMOUNT; SET DBID 320066378; # required when restoring control file in NOCATALOG mode RESTORE CONTROLFILE FROM TAG 'monday_cf_backup'; ALTER DATABASE MOUNT;Restoring the Database with a Backup Control File: Example
This example restores the control file, replicates it to all control file locations specified in the parameter file, and then restores and recovers the database:
CONNECT TARGET /
STARTUP NOMOUNT;
SET DBID 320066378; # required when restoring control file in NOCATALOG mode
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
RESTORE CONTROLFILE TO '/tmp/control01.ctl' FROM AUTOBACKUP;
RESTORE CONTROLFILE FROM '/tmp/control01.ctl'; # restores to all CONTROL_FILES locations
ALTER DATABASE MOUNT;
RESTORE DATABASE;
RECOVER DATABASE;
}
ALTER DATABASE OPEN RESETLOGS;
# if the database uses locally-managed temporary tablespaces, then add new tempfiles
# to these tablespaces after the RESETLOGS
SQL "ALTER TABLESPACE temp ADD TEMPFILE ''?/oradata/trgt/temp01.dbf'' REUSE";
Restoring Archived Redo Logs to a New Location: ExampleThis example restores all archived redo logs to the /oracle/temp_restore directory:
RUN
{
SET ARCHIVELOG DESTINATION TO '/tmp';
RESTORE ARCHIVELOG ALL;
}
Restoring a Control File Autobackup to a Nondefault Location: ExampleThis example restores the latest control file autobackup made on or before June 23, 2000 with a nondefault format of PROD_CF_AUTOBACKUP_%F. It starts searching for backups with a sequence number of 20, and searches backward for 5 months:
SET DBID 320066378; # required when restoring control file in NOCATALOG mode
RUN
{
SET UNTIL TIME '23-JUN-2001 00:00:00';
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE sbt TO 'prod_cf_autobackup_%F';
ALLOCATE CHANNEL CHANNEL_1 DEVICE TYPE sbt;
RESTORE CONTROLFILE TO '/tmp/autobackup_20001002.dbf' FROM AUTOBACKUP
MAXSEQ 20 MAXDAYS 150;
}
Restoring the Server Parameter File to Current Location: ExampleThe following shell script restores the current server parameter file in NOCATALOG mode:
#!/usr/bin/tcsh rman TARGET / <Restoring the Server Parameter File to a Nondefault Location: Example The following shell script restores a server parameter file that was backed up at least a month ago and restarts the database with the restored parameter file:
#!/usr/bin/tcsh echo "SPFILE=/tmp/spfileTEMP.ora" > /tmp/initTEMP.ora rman TARGET / <
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/54666/viewspace-17010/ ,如需转载,请注明出处,否则将追究法律责任。