Overview: I will explain RMAN fundamentals and work through
an example to demonstrate an RMAN restore.
Fundamentals
An RMAN restore is really just two commands:
- RESTORE DATABASE. This command
instructs RMAN to search the controlfile for a list of valid database
backups, select the most recent and issue a restore. A restore is simply
the placing of database files on disk.
- RECOVER DATABASE. This command tells RMAN: make the database consistent. Before a database can be opened, it must be consistent. Unless directed by Oracle Support, this rule can not be overturned, and is always enforced by the database.
Now, a consistent
restore is not necessarily complete. In Oracle terms, if a backup was taken
while the database was open (hence using archivelog mode), any recovery from
such a backup will be incomplete.
A backup taken from an open database in archivelog mode can
not backup the online REDO logs. So any changes recorded in a Redo log will not
be backed up, hence the reason why the restore is referred to as incomplete. This is not a problem,
since for most intents & purposes, a restore to the last available
archivelog is expected.
Example
We will use RMAN to restore a database called LIVE as the example process. We assume:
·
The database was in archivelog mode
·
Autobackup turned on
·
The backup & autobackup are available on
disk
In this example, commands to be typed are shown in bold - in
the context of the command output. Steps should be followed in the order given
since later steps depend on successful completion of previous steps.
- This
step may be optional. If the restore is to be done on a new server, then
this step is necessary, otherwise the instance may already exist. Create a
new Oracle instance called LIVE using these commands in a new Command
Prompt window:
CD /D C:\oracle\product\10.2.0\db_1\BINoradim -NEW -SID LIVE -SYSPWD password_live- In
this step, we will use RMAN to restore the latest spfile and controlfile
using what is known as an Autobackup.
An autobackup contains the controlfile and spfile of the LIVE database.
HUMAN INTERVENTION NECESSARY: You need to identify
the appropriate autobackup file. It is usually located in the latest-dated
sub-folder with an Oracle-generated name. When typing the commands below,
substitute the appropriate file names.
You will need to determine the appropriate controlfile path
& name for this step. Note that the entire file name is enclosed by single
quotes.
- Perform
the restore:
- Open
a Command prompt and type:
set oracle_sid=LIVE
rman target /Recovery Manager: Release 10.2.0.1.0 - Production on Thu Oct 27
16:18:41 2011Copyright (c) 1982, 2005, Oracle.
All rights reserved.connected to target database (not started)RMAN> startup nomount;startup failed: ORA-01078: failure in processing system parametersLRM-00109: could not open parameter file
'C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\SERVER\DATABASE\INITXE.ORA'starting Oracle instance without parameter file for retrival of spfileOracle instance startedTotal System Global Area
159383552 bytesFixed Size
1286292 bytesVariable Size
58724204 bytesDatabase Buffers
96468992 bytesRedo Buffers
2904064 bytesRMAN> restore spfile from
'C:\ORACLEXE\APP\ORACLE\FLASH_RECOVERY_AREA\XE\AUTOBACKUP\2011_10_27\O1_MF_S_765644418_7BLS3FWT_.BKP';Starting restore at 27-OCT-11using channel ORA_DISK_1channel ORA_DISK_1: autobackup found:
C:\ORACLEXE\APP\ORACLE\FLASH_RECOVERY_AREA\XE\AUTOBACKUP\2011_10_27\O1_MF_S_765644418_7BLS3FWT_.BKPchannel ORA_DISK_1: SPFILE restore from autobackup completeFinished restore at 27-OCT-11RMAN>RMAN> shutdown abort;ORACLE instance shut down.RMAN> startup nomount;ORACLE instance started.Total System Global Area 1677721600 bytesFixed Size
2066240 bytesVariable Size
318769344 bytesDatabase Buffers
1342177280 bytesRedo Buffers
14708736 bytesRMAN> restore controlfile
from 'E:\DSLD01\FRA\LIVE\AUTOBACKUP\2010_07_28\O1_MF_S_725565668_650RLONZ_.BKP';Starting restore at 29-JUL-10using channel ORA_DISK_1channel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:16output filename=+DG1/sby02/controlfile/control01.ctlFinished restore at 29-JUL-10RMAN> shutdown immediateORA-01507: database not
mountedORACLE instance shut
down.RMAN> startup mountORACLE instance
started.Total System Global
Area 1677721600 bytesFixed Size 2066240 bytesVariable Size 318769344 bytesDatabase Buffers 1342177280 bytesRedo Buffers 14708736 bytesDatabase mounted.
HUMAN INTERVENTION NECESSARY
: Note the following command requires
the correct folder/date to be substituted (similar to commands above).RMAN> catalog start with ‘E:\FRA\LIVE\BACKUPSET\2010_07_28\'
noprompt;Starting implicit
crosscheck backup at 29-JUL-10using target database
control file instead of recovery catalogallocated channel:
ORA_DISK_1channel ORA_DISK_1:
sid=479 devtype=DISKCrosschecked 8 objectsFinished implicit
crosscheck backup at 29-JUL-10Starting implicit
crosscheck copy at 29-JUL-10using channel
ORA_DISK_1Finished implicit
crosscheck copy at 29-JUL-10searching for all files
in the recovery areacataloging files...no files cataloged[Not all output shown,
ignore any errors]- Here
we perform the restore and recover. The Recover command may produce some
errors – ignore.
RMAN> RUN{ allocate channel disk1 type disk; RESTORE DATABASE; RECOVER
DATABASE;}allocated channel:
disk1channel disk1: sid=479
devtype=DISKStarting restore at
29-JUL-10channel disk1: starting
datafile backupset restorechannel disk1:
specifying datafile(s) to restore from backup setrestoring datafile
00001 to +DG1/live/datafile/system.256.619109535restoring datafile
00002 to +DG1/live/datafile/undotbs1.258.619109535restoring datafile
00003 to +DG1/live/datafile/sysaux.257.619109535restoring datafile
00004 to +DG1/live/datafile/users.259.619109535
...
channel disk1: reading
from backup piece E:\FRA\LIVE\BACKUPSET\2010_07_23
\O1_MF_NNNDF_TAG20100723T180022_64MLO798_.BKP
Make a cup of tea or two. This will take some time.
- At
this point, we should have an incompletely recovered database. RMAN should
say:
...archive log
filename=E:\FRA\LIVE\ARCHIVELOG\2010_07_28\O1_MF_1_4607_651BY17T_.ARC thread=1 sequence=4607media recovery complete, elapsed time: 00:01:23Finished recover at 29-JUL-10released channel: disk1
Continue with the process:
SQL> alter database set
standby database to maximize performance;Database altered.SQL> alter database open
resetlogs;Database altered.SQL> QUIT;
That’s the end of the RMAN
restore process.
No comments:
Post a Comment