Vous êtes sur la page 1sur 6

RMAN Recovery Methods

When performing a restore operation, it is best to open two telnet sessions, one for SQL commands, and one for RMAN commands. or the rest of this doc!ment, RMAN commands will be prefaced with the RMAN" prompt, and SQL commands will be prefaced with the SQL" prompt. A # indicates that the command is e$ec!ted from the %ni$ prompt.

Restoring and Recovering All &atafiles


In this scenario, it is assumed that your control files are still accessible. You have a backup, done for example with backup database plus archivelog; Your first step is to make sure that the target database is shut down: $ sqlplus / as SYSDBA SQL> shutdown abort; ORACLE instance shut down Next, you need to start up your target database in mount mode. R !N cannot restore datafiles unless the database is at least in mount mode, because R !N needs to be able to access the control file to determine which backup sets are necessary to recover the database. If the control file isn"t available, you have to recover it first. Issue the #$!R$%& '%N$ command shown in the following example to mount the database: SQL> startup mount; Oracle instance started !atabase "ounted #ince backup set files are created in an R !N(specific format, you must use R !N to restore the datafiles. $o use R !N, connect to the target database: $ rman target / rcvcat rcvcat/rcvcat@oemprod $he remainder of this example shows how to restore all of the datafiles of the target database. When the restore command is e$ec!ted, RMAN will a!tomatically go to its last good bac'!p set and restore the datafiles to the state they were in when that bac'!p set was created. )hen restoring database files, R !N reads the datafile header and makes the determination as to whether the file needs to be restored. $he recovery is done by allocating a channel for I*' and then issuing the R !N restore database command. )ith (racle)i and above, you don"t need to allocate a channel explicitly. Instead, you can use the default channel mode: R#A$> restore database; R#A$> recover database; SQL> alter database open; +or (racle*i, the !,,'-!$., R.#$'R., and R.-'/.R commands need to be enclosed by the run01 command: R#A$> run { allocate channel d restore database; recover database; $ alter database open;

t!pe d"s#;

(nce the recovery has been completed, e$ec!te a complete RMAN bac'!p to establish a new baseline.

Restoring Specific +ablespaces


In this scenario, it is assumed that your control files are still accessible. You have a backup, done for example with backup database plus archivelog; $ake the tablespace that needs recovery offline, restore the tablespace, recover the tablespace, and bring the tablespace online. If you cannot take the tablespace offline, then shutdown abort the database and restore in mount mode. +irst try to take the tablespace offline2 $ sqlplus %/ as s!sdba% SQL> alter tablespace tab o&&l"ne; %& this works' continue with the R#A$ recover() $ rman target / rcvcat rcvcat/rcvcat@oemprod R#A$> restore tablespace tab; R#A$> recover tablespace tab; SQL> alter tablespace tab onl"ne; If taking the tablespace offline fails, follow these steps: $ sqlplus / as SYSDBA SQL> shutdown abort; SQL> startup mount; $ rman target / rcvcat rcvcat/rcvcat@oemprod R#A$> restore tablespace tab; R#A$> recover tablespace tab; SQL> alter database open;

(nce the recovery has been completed, e$ec!te a complete RMAN bac'!p to establish a new baseline. Restoring Specific &atafiles
In this scenario, it is assumed that your control files are still accessible. You have a backup, done for example with backup database plus archivelog; $ake the datafile that needs recovery offline, restore the datafile, recover the datafile, and bring the datafile online. If you cannot take the datafile offline, then shutdown abort the database and restore in mount mode. +irst try to take the datafile offline: SQL> alter database data&"le '/u( /oracle/db/A)* /tab/A)* +tab,db&' o&&l"ne; %& this works' continue with the R#A$ recover() $ rman target / rcvcat rcvcat/rcvcat@oemprod R#A$> restore data&"le '/u( /oracle/db/A)* /tab/A)* +tab,db&' R#A$> recover data&"le '/u( /oracle/db/A)* /tab/A)* +tab,db&' SQL> alter database data&"le '/u( /oracle/db/A)* /tab/A)* +tab,db&' onl"ne; If taking the datafile offline fails, follow these steps:

$ sqlplus / as SYSDBA SQL> shutdown abort; SQL> startup mount; $ rman target / rcvcat rcvcat/rcvcat@oemprod R#A$> restore data&"le '/u( /oracle/db/A)* /tab/A)* +tab,db&'; R#A$> recover data&"le '/u( /oracle/db/A)* /tab/A)* +tab,db&'; SQL> alter database open;

(nce the recovery has been completed, e$ec!te a complete RMAN bac'!p to establish a new baseline. Restoring ,ontrol iles
In this scenario, it is assumed that your control files are backed up. You have a backup, done for example with backup database plus archivelog; In an ideal world you"ll never use R !N to restore a control file. 3ut if something catastrophic happens, and you lose all control files, here are the steps for getting them back: $he following examples assume that you are using a catalog. +irst, here"s the simplest 'racle4i syntax for restoring a control file: $ sqlplus / as SYSDBA SQL> shutdown abort; SQL> startup nomount; $ rman target / rcvcat rcvcat/rcvcat@oemprod Set the database id *!+%!, with the &ollowing co""and -his is a ./0digit nu"ber that R#A$ uses to uni1uel( identi&( this database in the recover( log -he nu"ber can be obtained &ro" an( previous R#A$ backup log &ile R#A$> set db"d - ..........;

R#A$> restore control&"le; SQL> alter database mount; SQL> alter database open; If this fails with ... /0A1( 2345 must use 06S678/9S or :/06S678/9S opt"on &or database open ... then you must perform a recover database: SQL> shutdown abort; SQL> startup mount; $ rman target / rcvcat rcvcat/rcvcat@oemprod R#A$> recover database; SQL> alter database open resetlogs; R#A$> reset database;

Note, that all offline archivelogs are now !seless, perform a f!ll bac' as soon as possible. Restoring (nline Redologs
In this scenario, it is assumed that your control files are backed up. You have a backup, done for example with backup database plus archivelog2

$ s1lplus 23 as s(sdba2 SQL> shutdown abort; SQL> startup nomount; $ rman target / rcvcat rcvcat/rcvcat@oemprod Set the database id *!+%!, with the &ollowing co""and -his is a ./0digit nu"ber that R#A$ uses to uni1uel( identi&( this database in the recover( log -he nu"ber can be obtained &ro" an( previous R#A$ backup log &ile R#A$> set db"d - ..........; R#A$> restore control&"le; SQL> alter database mount; R#A$> restore database; R#A#> recover database; R#A$0//45.) R#A$0//478) R#A$0//45.) R#A$0/=//>) R#A$0/7/4@) 66666666666666666666666666666666666666666666666666666666666 666666666666666 ERROR #ESSA9E S-AC: ;OLLO<S 666666666666666 66666666666666666666666666666666666666666666666666666666666 &ailure o& recover co""and at /83>?3>//@ ..)/=)>= "edia recover( re1uesting unknown log) thread . se1 . lowscn ?@@?@.@

#ince the online logs were lost, complete recovery is not possible. 'pen the database with resetlogs to continue. R#A$> alter database open resetlogs; 1111111111111111111111111111111111111*;</07A:71111111111111111111111111111111111111111111 Dur"ng th"s t!pe o& recover!= "& !ou rece"ve error messages l"#e th"s5 R#A$> restore database; Starting restore at ..0ABL0/4 using channel ORACS+-C-ADEC. using channel ORAC!%S:C. R#A$0//45.) 66666666666666666666666666666666666666666666666666666666666 R#A$0//478) 666666666666666 ERROR #ESSA9E S-AC: ;OLLO<S 666666666666666 R#A$0//45.) 66666666666666666666666666666666666666666666666666666666666 R#A$0/=//>) &ailure o& restore co""and at /53..3>//4 .@)>4)>> R#A$0/7/>7) so"e targets not &ound 0 aborting restore R#A$0/7/>=) no backup or cop( o& data&ile ./ &ound to restore R#A$0/7/>=) no backup or cop( o& data&ile 8 &ound to restore R#A$0/7/>=) no backup or cop( o& data&ile ? &ound to restore R#A$0/7/>=) no backup or cop( o& data&ile 5 &ound to restore R#A$0/7/>=) no backup or cop( o& data&ile 7 &ound to restore R#A$0/7/>=) no backup or cop( o& data&ile 4 &ound to restore R#A$0/7/>=) no backup or cop( o& data&ile @ &ound to restore R#A$0/7/>=) no backup or cop( o& data&ile = &ound to restore R#A$0/7/>=) no backup or cop( o& data&ile > &ound to restore R#A$0/7/>=) no backup or cop( o& data&ile . &ound to restore >use the &ollow"ng d"rect"ons to recover ?recreate the control&"le@5 A"th the database mounted= e.ecute Balter database bac#up control&"le to trace resetlogs;C <er&orm a shutdown abort on the database= but rema"n at the SD8E prompt, *n another telnet sess"on= go to the udump d"rector! to retr"eve the result"ng trace &"le and cop! "t to another locat"on to ed"t "t,

6d"t the &"le and add the phrase unt"l cancel to the recover database command at the end, 7he phrase should read recover database unt"l cancel us"ng bac#up control&"le, 0emove the alter database open command a&ter the recover command, Save the &"le w"th a ,sql e.tens"on, Bac# at the SD8E prompt= e.ecute the mod"&"ed trace &"le, Ahen prompted &or an arch"ved log= t!pe "n cancel and the repl! should be med"a recover! cancelled, *ssue alter database open resetlogs, 7he database should open a&ter a &ew moments, Fonnect to the 0;A: recover! catalog and "ssue the reset database command, <er&orm a &ull 0;A: bac#up as soon as poss"ble,

1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

+ime-.ased, ,hange-.ased, or S,N-based /ncomplete Recovery


Incomplete recovery uses a backup to produce a non(current version of the database. In other words, you do not apply all of the redo records generated after the most recent backup. You usually perform incomplete recovery of the whole database in the following situations: o o o o edia failure destroys some or all of the online redo logs. ! user error causes data loss, for example, a user inadvertently drops a table. You cannot perform complete recovery because an archived redo log is missing. You lose your current control file and must use a backup control file to open the database.

$o perform incomplete media recovery, you must restore all datafiles from backups created prior to the time to which you want to recover and then open the database with the R.#.$,'5# option when recovery completes. $he R.#.$,'5# operation creates a new incarnation of the database2 in other words, a database with a new stream of log se6uence numbers starting with log se6uence 7. :/76 G Start ever! 0;A: "ncomplete recover! w"th the &ollow"ng commands5 $ s1lplus 23 as s(sdba2 SQL> shutdown abort; SQL> startup mount; $ rman target / rcvcat rcvcat/rcvcat@oemprod

11Hor t"me1based recover!= use these commands5 R#A$> restore database unt"l t"me %to+date?'(I/ J/(2 R#A$> recover database unt"l t"me %to+date?'(I/ J/(2 "edia recover( co"plete SQL> alter database open resetlogs; 11Hor SF:1based recover!= user these commands5 R#A$> restore database unt"l scn (((; R#A$> recover database unt"l scn (((; "edia recover( co"plete SQL> alter database open resetlogs; 11Hor change1based recover!= user these commands5 R#A$> restore database unt"l sequence 44JM; R#A$> recover database unt"l sequence 44JM; "edia recover( co"plete SQL> alter database open resetlogs; 11Arch"ved log sequence number 11Arch"ved log sequence number J5(5(('=';;/DD/YY KKJL5;*5SS'@%; J5(5(('=';;/DD/YY KKJL5;*5SS'@%;

(nce the recovery has been completed, e$ec!te the following steps0
Delete pr"or bac#ups w"th th"s command ?&rom the 0;A: prompt@5

R#A$> delete &orce backup; +his command removes all prior bac'!ps from the RMAN catalog as they can no longer be !sed once the database has been restarted with the resletlogs option. After completing this command, create a new RMAN bac'!p to establish a new baseline.

Recovering Archived Logs only


In the event that you want to recover the database archived redo logs until a desired time, you can use the following commands:

$ rman target / rcvcat rcvcat/rcvcat@oemprod R#A$> restore A0FK*N68/9 H0/; 7*;6 'SYSDA761 ' O:7*8 7*;6 'SYSDA76'; or R#A$> restore A0FK*N68/9 H0/; 7*;6 %to+date?'(I/ O:7*8 7*;6 'SYSDA76'; /(2 ((5((5( '=';;/DD/YY KKJL5;*5SS'@

Vous aimerez peut-être aussi