RMAN Restore Example
There are many ways to restore a database using an RMAN backup - this example assumes you are performing a Disaster-Recovery restore of all data and recovering the entire database with the same SID and the same disk/tablespace layout.
You will need the following information:
Database SID: ________
Database SYS password: ________
Disk layout and sizes: ________
Database ID (DBID): ________
There are 5 steps to recover the database:
1) Create a new (empty) database instance
2) Mount the instance
3) Restore the datafiles
4) Recover the database
5) Reset the logs
1) Create a new (empty) database instance
Configure the new server with same disk layout as the original database - if necessary use Symbolic Links (or in Windows use disk manager to re-assign drive letters.)
Ensure you have enough disk space for both the backup files plus the restored database files.
Create a new database with the database configuration assistant (DBCA) and set the SYS password and global database_nameto the same as the original database.
If the database to be restored is in archive log mode, set the LOG_ARCHIVE_FORMAT parameter to match the setting in the original database.
The ORAPWD utility can also be used to change the SYS password.
Set the environment variable NLS_LANG for your character set -
NLS_LANG=American_America.WE8ISO8859P1
2) Mount the empty instance
SQL> Shutdown immediate;
SQL> Startup mount;
or specifying the pfile explicitly:
SQL> CREATE PFILE='C:\oracle\Database\initLive.ora' FROM SPFILE;
SQL> Shutdown immediate;
SQL> Startup mount pfile=C:\oracle\Database\initLive.ora
3) Restore the datafiles
In this case we have copied the RMAN backup files and archive logs to R:\Rman\
Change the dbid to match that of the database being restored
RMAN> SET dbid = 477771234;
RMAN> run {
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT 'R:\Rman\%U';
restore database;
}
At this point the datafiles and tablespaces will be re-created. For a large database it can take a long time to restore each tablespace - for better performance during a restore place the RMAN backup files on a separate disk to the Oracle datafiles to reduce disk contention.
4) Recover the database
SQL> Recover from 'L:\oradata\live' database until cancel using backup controlfile;
SQL> cancel
5) Reset the logs
SQL> alter database open resetlogs;
This will update all current datafiles and online redo logs and all subsequent archived redo logs with a new RESETLOGS SCN and time stamp.
As soon as you have done a resetlogs run a full backup, this is important as should you suffer a second failure you will not be able to perform a second recovery because after resetting the logs the SCN numbers will no longer match any older backup files.
Notes:
The DBID can be retrieved in several places, if the database is running: Select dbid from V$DATABASE;
The RMAN client displays the dbid at startup when connecting to a database:
Copyright (c) 1995, 2003, Oracle. All rights reserved.
connected to target database: RDBMS (DBID= 7776644123)
The default filename format for an RMAN controlfile autobackup is c-IIIIIIIIII-YYYYMMDD-QQ, where: IIIIIIIIII is the DBID.
“This only is denied even to God: the power to undo the past” - Agathon
Related Commands:
BACKUP - Back up database files, archive logs, backups, or copies.
CROSSCHECK - Check whether backup items still exist.
LIST - List backups and copies
RECOVER - Perform media recovery from RMAN backups and copies.
RESTORE - Restore RMAN backups and copies.
REPORT - Report backup status: database, files, backups
RUN - Some RMAN commands are only valid inside a RUN block.
SET - Settings for the current RMAN session.
SHOW - Display the current configuration
原文出處:RMAN Restore example - Oracle - SS64.com