How to restore and recover a database from an RMAN backup. (Doc ID 881395.1)

APPLIES TO:

Oracle Database - Enterprise Edition - Version 10.1.0.2 to 11.2.0.2 [Release 10.1 to 11.2]
Oracle Database - Enterprise Edition - Version 11.2.0.4 to 11.2.0.4 [Release 11.2]
Oracle Database - Enterprise Edition - Version 11.2.0.3 to 11.2.0.3 [Release 11.2]
Oracle Database - Enterprise Edition - Version 12.1.0.1 to 12.1.0.1 [Release 12.1]
Oracle Database Cloud Schema Service - Version N/A and later
Information in this document applies to any platform.
***Checked for relevance on 21-AUG-15 ***

GOAL

The following note will guide a DBA through the process of restoring and recovering a database from an RMAN backup. It will assist in a complete database restore.
The following instructions will restore the backup and recovery process DBA database through RMAN. It will help complete a full database restore
Assumption    assume
- A valid backup of the database is accessible.    Effective Backup can access the database
- the Required Archive logs . Recover to the Available and Accessible at The Database are    needed to restore the database archive logs * available and accessible.
Archive logs are required Generated from Those at The Start Backup at The Time of Completion of an until at The IF AN at The Backup Online Backup WAS Performed. 
Necessary archive log backup from the start time to backup is completed (If you perform an online backup) generated log

If you need to perform restore/recovery on a different host for a backup taken on another host, also refer:

If you need to perform a restore / recovery on another host for backup on another host, please refer to

Note 419137.1 How To Restore Rman Backups On A Different Node When The Directory Structures Are Different

SOLUTION

How to restore a complete database from an RMAN backup  如何从RMAN备份还原完整的数据库

This note assumes an RMAN catalog is not available. The use of a catalog is optional in this scenario as the backup information is available in the controlfile.

This explanation assumes RMAN directory is not available. In this case, use the directory is optional, because the control file backup information provided

Prior to restoring a database you must ensure you have a valid RMAN backup.
Prior to restore the database, you must ensure that you have a valid RMAN backup.
In this example we will assume all files are required to be restored:
In this example, we assume that the need to restore all files:
* the Datafiles
* Controlfiles
* archivelogs (an In the Order to the perform Recovery)

Online redo logs and the TEMP Files are recreated Automatically by RMAN the when A RESETLOGS IS Issued Online redo logs and the TEMP Files are not. backed up by RMAN
When issued reset the log, RMAN will automatically re-create the online redo logs and temporary files. RMAN does not back up online redo logs and temporary files

Step 1: Identify controlfile backup to restore   you sure you want to restore the control file backup

Note:  the If you do not need to Restore A controlfile the proceed to the STEP 3.   If you do not restore the control files, proceed to  step 3


* Locate the RMAN backup you wish to   restore. Find RMAN backup you want to restore.
* These files should be located in the   directory where they were backed up to. These files should be located in their backed up to the directory.
* If you have the RMAN backup log  available this will also be of assistance. If you have available RMAN backup log, which will also help.

Within the RMAN backup log you will see  the controlfile is backed up last the the piece handle is shown.
In RMAN backup log, you will see the last backup control file, and shows a fragment of the handle
....
Including Current Control File Backup in the SET
Including Current Backup SPFILE in the SET
Channel ORA_DISK_1: Starting piece ... 2009/01/01 1 AT 12 : 00: 00
Channel ORA_DISK_1: Finished piece ... AT. 1 2009/01/01 12:00:02
piece ... handle = / <path FRA> /o1_mf_ncsnf_TAG20090506T11_501tr0h7_.bkp  Tag = TAG20090506T11 Comment = NONE
Channel ORA_DISK_1: Backup Complete SET, Elapsed Time: 00 : 00: 02

the If you do not have have the locate Simply log AN RMAN Backup File RMAN at The Last backed up This Should Contain at The Backup controlfile..
If you do not RMAN backup log, you can just find a file on RMAN backups. This should include a control file backup.

Step 2:  Restore the controlfile

2A)  the If you  DO the NOT  have have A spfile .

The If you do have have AN spfile or init.ora the Move to the Step 2b   If you have spfile or init.ora, go to step 2b

If you do not have a valid spfile or init.ora RMAN has the ability to nomount an instance without the requirement of a spfile. This will allow you to restore your spfile from a valid backup.

If you do not have a valid spfile or init.ora, RMAN can uninstall the instance without the need for the spfile. This will allow you to restore spfile from a valid backup.

% rman target /

RMAN> startup nomount force;

 

You will see this message:   You will see the following message:
..
Starting the Oracle instance for the without the Parameter File Retrieval of SPFILE
Oracle instance starts without parameters to retrieve the file SPFILE
..
At the this Restore Point you CAN at The spfile:   At this point, you can restore spfile:
RMAN> restore spfile from '/<FRA path>/o1_mf_ncsnf_TAG20_501tr0h7_.bkp';

RMAN> shutdown immediate;

 

Once the spfile has been successfully restored proceed to Step 2b.  

2b)

SQL> startup nomount;

 

Following the successful nomount of the instance you  are ready to restore the controlfile;  Once you have successfully executed instance, you can restore the control file.
NOTE: The controlfile will be restored to the following location:
Note: The control files are restored to the following locations:
SQL> show parameter control_files

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /<oradata path>/control01.ctl

 

% rman target /

 

You will see the message:   You will see the following message:

Connected to target Database: V11 (not Mounted)
RMAN> restore controlfile from '/<FRA path>/o1_mf_ncsnf_TAG20090506T113947_501tr0h7_.bkp';

Starting restore at 2009/05/11 11:01:26
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=151 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/<oradata path>/control01.ctl
Finished restore at 2009/05/11 11:01:27
In this example the controlfile has been restored to  '/<oradata path>/control01.ctl'

Step 3:  Restore and recover the database

Your next task is to restore the database and perform recovery.  Mount the database now that the controlfile has been restored:

The next task is to restore the database and perform recovery. Has now regained control file, mount the database:

RMAN> alter database mount;

 

Now you have two options for recovery.    Now, you have two recovery options.

1) Full / Complete recovery.  Complete recovery
2) Point In Time Recovery (PIT  ) based on the point of time of incomplete recovery

In both examples it is assumed that all archivelogs are available to perform the recovery.

In both examples, assume that all archive logs can be used to perform the recovery.

Full recovery
==========

To Perform a full restore and recovery.

run{
restore database;
recover database;
alter database open resetlogs;
}

 

If you performed a complete recovery with current controlfile and online redologs in place, you might get below error when opening the database with resetlogs:
If you are using the current control files and online redo logs to perform a complete recovery, then log in using open database reset , you may encounter the following error:
ORA-01139: the RESET LOGS! Valid only the After the Option AN - incomplete Database Recovery
At the this Open at the Point Simply RESETLOGS Database the without the Option.

At this point, you can simply open the database without resetlogs options.

Recovery PITR
===========


Point-the In-Time Recovery (PITR) Would you have have BE IF was advertised. Used to Restore Database A to A Particular Point in Time. On May This warranted for BE A Hardware Fault or IF you are aware of a database corruption that occured at a certain date / time.
If you decide to restore the database to a specific point in time, point in time recovery (PITR) will be used. If a hardware failure occurs, or if you know / time database corruption occurs on a specific date, you may need to do this.

run{
set until time "to_date('Aug 16 2014 10:30:00','Mon DD YYYY HH24:MI:SS')";
restore database;
recover database;
sql 'alter database open resetlogs';
}

  

NOTE: The above scripts may be altered to allocate more channels Good practice would be to review the backup log and use the same number of channels for restore as that used by the backup..  Note: You can change the script above to assign more channels. Good practice is to view the backup log, the same number of channels and use the backup used to restore.


REFERENCES

NOTE:419137.1 - How To Restore Rman Backups On A Different Node When The Directory Structures Are Different

Guess you like

Origin www.cnblogs.com/zylong-sys/p/11990732.html