You are on page 1of 16
a. i 1 1. w wa wa = w wi : = : L - - 1 L x ™ race 10° - Backup & Recovery Scenarios (1 of 4) Pago 81 of 203, Wa: 3-Day. 33 27, Backup & Recovery Scenarios - 1 27.1, CASE 1: Full Database Recovery We backup our database every night at 10PM, We have our Database running in Archivelog mode. On Tuesday at 41:00AM we lost everything. (How? we don't know). ‘Target: Try to get as much as possible Observation: The last Archivelog file got generated was about 10:58AM, Action: Since we lost everything, we have to depend on yesterday's backup (Monday night's backup). Which means ‘wo will apply all “available” Archivelog files (generated on Tuesday), on top of Monday Night's Database. Does Monday's Backup needs Recovery? Certainly nat! But we are forcing it to under-gi Recovery (after Restore). ‘As far as Monday Night's Backup is concemed, that Controle says everything is fine (as far all SCN numbers are concerned), But, since we want to apply Tuesday's Archivelog files on top oft wevare going. to treat the Monday's, Contrffile as "Backup-Controlfle”, and the recovery is known as "In-Complete Recovery’ Complete Recovery can only be done in case of Present Contrlfle (in this case Tuesday's'41 AM Filg)y 1. Current On-Line-Redolog (-do) file's availabilty. In case of either the fle is missingwe‘€an only do "In- Complete Recovery", So, inthe above case, we issued a comarand fo perform ICR, ### At the OS Level, first RESTORE all 3 types of DB-Files Then SQL> STARTUP MOUNT / SQL> ALTER DATABASE RECOVER AUTOMATIC USING BACKUP CONTROLEILE UNTIL CANCEL: SQL> RECOVER CANCEL; ‘ SQL> ALTER DATABASE OPEN RESETLOGS; (The reason we are resetting the LOG files is beeduse, the REDOS we have from Monday are at lower sequence number than our DBFs, since we have applied Tuesday’ Archivelog les). In the above scenario, after the recovery, ive ate fine except we lost latest changes made by users, which were recorded in the Current-On-Line-Redolog fle which was lost. + Why we're treating Monday's controile asackup controle? + Why we're saying i's in-complete recovery? + Why we have to reset-iodal the end of the recovery? 27.2. CASE 2: Lossof a Non-SYSTEM datafile th resulted in loss of a Database file (On Thursday moming’at 10:30 AN yve lost a UNIX File system, ‘Tablespace: ‘USERS_DATA" (has 4 datafiles associated with it) Datafile: “idiskt/oradata/QRGLiusers_datat dbt Observatfon: Since'we fost this fle, users are gotting an Oracle-Error message, saying that datafile" not found, cas do not Target: Would Tike to fx this problem orine, since there are other users who are working in other tablesp ant to stop working. Type: For this scenario we can perform Offine or Online Complete Recovery. (On-line recovory is not possible in case If the data. fle belongs to SYSTEM TS) So, if the file is lost which belongs to SYSTEM-TS, then we can only perform offline CR. ‘Action: Aer fixing the UNIX FS, we have copied only the lost datafile fcom our Wednesday night's backup. This file ig surely at an outdated SCN, which needs to be "Rec When a non-SYSTEM data fils is lost, there are three manual methods by which the data fle can be recovered, 27.2.1, Method 1: Database Recovery Now lets test the first method in recovering this database by using RECOVER Di ZRELLE command: SQL> STARTUP MOUNT SQL> RECOVER DATABASE; SQL> ALTER DATABASE 0} wanleivesot.com Wilshice Sofware Technologies Rey, Dt 27-Apr-08 Ph: 2761-2214 5577-2214 Version: Oracle 109 - Backup & Recovery Scenarios (1 of 4) Page 82 of 203 : WK: 3-Day: 33 (To do the database recovery, which requires the database to be mounted but not open (offine recovery). 27.2.2. Method 2 : Data File Recovery ‘This method involves taking the data file offine and opening the database before issuing the RECOVER DATAFTL ‘command; SQL> STARTUP MOUNT - No need if database already opened. SQL> ALTER DATABASE DATAPILE ‘/diskl/oradata/ORCL/ucer_datal dbf! OFFLINE; SQL> ALTER DATABAE OPEN; = No need if database is already open. ‘SQL> ALTER DATABASE RECOVER AUTOMATIC DATAFILE /disk1/oradata/ORCL/user_datat.dbf"; SQL> ALTER DATABASE DATAPILE | /dick1/oradata/ORCL/user_datal.dbf' ONLINE; 27.2.3, Method 3 : Tablespace Recovery You canals perform a tablespace recovery. This method requites tablespace tobe options the databases oper SQL> STARTUP MOUNT & . S0L> ALTER DATABASE DATAFILE ' /DTSK1/ORADKTA/ORCL/USER fe Segue; SQ1> ALTER DATABASE OPEN; (Perform above statements only when your database is down) ‘SQL> ALTER TABLESPACE USER_DATA OFFLINE; sql> RECOVER TABLESPACE USER DATA; Sql> ALTER TABLESPACE USBR_DATA ONLINE it up Wathe FighBSEN number and can function A this point using any one of these methods, the fle ib ‘normaly In this scenario, we haven't lost any data, We did use 1, Present Controtfile 2. Current Redo Log fe, which resus in "Comp Recovery Since we have Present-controifle & Current-On- Redaley files, we Gon't need to use “using backup controlfile” or “until cancel” options. And also we didn't néed to "RESET" ‘Wages Log files, as this is "Complete Recovery’. The Gil eiteronce in ON-LINE: Recovory and OFF-LINE Regovery fe users are working in Oncine and stance is UP. But while recovering, we are mentioning thé ime of the'file which we have restored from the previous night and hich needs necovesy” Winters ag in OFF-LINE recovery. since the database was just mounted, we could able to do MMosover automatic” and that Keytord knows which dala to fie (need not mention the fle name as in Ortine- Recover), Both procedures vould work fine. I js PSL choice which one to plekup. 27.3. CASE 3 : STARTUP MOUNT SQi> RECOVER DATABASE; SQL> ALTER DATABASE OPEN; ‘Note that ifthe disk crash has damaged several data files, then all the damaged data files need to be restored from the backup, ‘The database needs to be mounted and the recover database command issued before the ‘database can be opened 274. CASE 4: Loss of an Object and Point in Time Recovery. ‘One of the managers dropped a table around 2PM on Tuesday and realized this stupid thing at 4PM. OBSERVATION: People are working left & right on the system wor ahivesof com Wilshive Sofware Technologies Rev. Ot 27-Ape06 Ph: 2761-228 8877-2214 Version: 4 Oracle 10° Backup & Recovery Scenarios (1 of 4) Page 83 of 203 - WK:3- Day 33 Choice: You ask the manager, f he provide the table as of yesterday could satisfy him. If he says yes all you have to dois: $ imp eyten/manager fromusersscott tousersscott tables-enp \ file~exp.dap (Using this method, you are basically extracting the table from your logical backup without touching any physical files or restoreltecovery procedures), In case if he did some modifications to this table, which he says, cart loose, you hhave no choice but go for recovery. But there is some thing to understand here before preceding any further. The issue is, somehow if we can go back to 2PM, would that do or not? This is the question you should ask your end. users. If they say, it's fine, your problem is simplified. But if they say that is not en accepted choice - which means, they need to have the database as itis (he way it locked at 4PM). This would be a difficult case for the DBA, since hhe has to first get TABLE (do TIME-BASED-RECOVERY up to 2PM) and again go up to 4PM, Hore you should see i there is any other server avaliable for you. In case itis available, your work is reduced to 25%, but the server must be of exactly of same type (OS, Oracle Version etc.). And it should have enough disk-space to do- RESTORE of your last night's backup. (For e.g. we call the server as our Development Server where as the “TABLE DROP* occurred on our Production Bow) aN ‘The most unfortunate thing is Oracle can't walk backwards. Please dont think thative canigo back in time (which means, we can put 4PM database and go back to 2PM). This is not possible Oracieoffers "Roll Fonvard” ‘mechanism only. (Don't confuse this word by comparing with "commit" & “rollback”. which is onl)iper transaction basis). So, now we are on development server (which means we hve A0li¢hed our production server yet. End- Users are ‘tll working on the Prod). On the Development, "RESTORE dast-night's Production dgfabase, And also copy all the "ARCHIVELOG" files from "PRODUCTION" to "DEVEL IT" which were gatirated today. These files ere going to’help us in performing “ROLL-+ coe aay ae" ek RECOVERY’ SQL> STARTUP MOUNT; Lo SQL> ALTER DATABASE RECOVER AUTOMATIC“ USING BACKUP CONTROLFILE UNTIE-TIME *2G94-10-24-14:00:00 SQL> ALTER DATABASE OPEN RESETLOGS; z Noi you should be ele te ae ho EMP Tetie une tazrr lyou goo: wis. known a8 ‘TIME-BASED ‘After doing this, we should have the table EMP in‘our Production Server also. By doing this way, we really didn't touch our production End-Users and atthe saié tine, we saved our Manager by giving him his LOST Table EMP back. Butif there is no other server except cur Prod, then pérform the fllowing steps ‘Ask your users to exit.did petform Backup. This-backup we call it as @ BACKUP_APM, Now restore your LMFpackup. Doa eee as expitined shove Export the table but of he Shutdown this database Restore itgzoriginal 4PM database performed in Stepi 7. impor tis blethm Stop) ito Seats acount So doing thidiay, tee is extra effort (backing up the 4PM database, which wil take some time) But ether method you take, basicaly.by Going through TIME-BASED recovery, lost objacts can be brought-over. 27.5. CASE 5: Loss of an Un-archived Online Log File PROBLEM: A power surge caused the database to crash and also caused 2 media failure, losing all the online log files. Al the data files and the current control files are intact OBSERVATION: Altiough the data fles are OK after the crash, these fles cannot be used because crash recovery cannot be performed (since all online log files are lost). Forcing the database open in a situation tke this can cause database inconsistency. If any of the un-archived log fies are lost, crash recovery cannot be performed and, instead, ‘media recovery needs to be performed. SOLUTION: In this case, all the dataflles need to be restored from an ontine (or offine) full backup and rolled forward untl the ast available archived lag file is applied. Since this is incomplete recovery. 9 ep /diskt/oradata/DEMO/BKUP/*.dbf /diskl/oradata/DEMO SQL> STARTUP MOUNT SQL> ALTER DATABASE RECOVER AUTOMATIC UNTIL CANCEL; wor wshiresoR com \Wishice Sotwara Technologios Rev. Dt 27-Apr05 Ph: 2761-2214 §877-2214, Version: 4 Oracle 107 Backup & Recovery Scenarios (1 of 4) Poge 84 of 203, : WK'3-Day 33 SQL> RECOVER CANCEL; SQL> ALTER DATABASE OPEN RESETLOGS; [Note that all the datafiles need to be restored from the backup before applying recovery. The recover database until cancel command lets you apply the logfiles one at a time, and you can cancel when the last archive log fle is applied. After recovery, Oracle creates the online log files automaticaly when the database was opened with the RESETLOGS option. Multiplexing the log flles is strongly recommended to protect the database from loosing the conline log files. 27.6. CASE 6: Recovery with a Backup Control File Description: Accidentally contotfile is deleted and we didnt have any current copy of the controle. Now we had copied the controle from the backup and tried to start up the database, While opening the database, Orage complained that an old control file was being used, Choice: In this case, we have two options. Where all our datafiles and online log fles arate, we can create a new control file using the create contrelfite command, perform recovery if requited, and start up the database Alternatively, we can use the backup control file, SOLUTION: if you use a backup contra! fle, you need to perform media recovery. Al the using backup controlfile option. Once recovery is done, yo start ase with the RESETLOGS option, and you have to take a complete backup of your dalabase For this tse the first solution inthis case. 27.6.1. Method 1: The presence af a traced contro! file is very helpful in this cag. But migke sure TaLAbIS traced contol file is a latest copy of the Iatest structure of the database, ie, no sett a "lo the détabase after the control fle was unt 2 tactd, Finally, executed hs traced contol al the NOMOUNT lage. i tated conta fle sno preset, @ CREATE GORTROLFLE sept has be sutimanaly. kn Rs acct ibe datas and the edo es 891> STARTUP NowooNT, S0L> CREATE COMTROLEILE REUspnaTAAAGH’ “acer” aRcHIVEIOG RESHTLOGS toorite GRoUE 1 ( : */atekl /oredate/acie/eadbia tog’, Sosa Results The databases back, without eny data loss, an tle dounime 27.6.2. Method 2: $ op /disk3/oradata/ACCT/BHUP/cont1.ctl /diski/oradata/ACcD SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL; (ifit needs more recovery then apply the online redo log files) SQL> ALTER DATARASE OPEN RESETLOGS; When you use a backup control file, you must use the USING BACKUP CONTROLFILE option with the recover database command, “>” Gracie 109 - Backup & Recovery Scenarios (1 of 4) Page 85 of 203 . WHS Day. 4.4 Backup & Recovery Scenarios - 2 27.7. CASE 7: Loss of a Non-SYSTEM Data File with Rollback Segments PROBLEM: On Monday morning, due to 2 media failure, all the data files that belong to the rollback segments tablespace ROLLBACK DATA were lost. Once we took the data file offine and opened the database, to select from a user table and got the Oracie error: that file cannot be read. SOLUTION: If the data fle that is lost belongs to a rollback segment tablespace, recovery could be tiicky. For performing online recovery we have to take all the data files offine thal were lost during the media failure. This means that all the rollback segments that belong to the data fle need ta be recovered. Jn this test, to simulate the loss of data files, we will shut the database down with the ABORT option and delete the data fle belonging to the ROLLBACK, DATA tablespace at the OS level: rn SQL> CONNECT scoPT/TIGER SQL> DELETE FROM EMP] WHERE RONNUMCIO; SQL> SHUTDOWN ABORT SOL> Ex? = % Siz Taiaea/oradaca/om0/sbedatadt bt fue i 2? Before we start recovery, a very important stop needs io be performer The ora ae 10 be mosie, ae NRSLLOACIC SEGMENTS parameter rouse to be commend ou iistenel dare, vec wil ro be aie find the existing roback segments an you went be able to opethe daa one sgl> STARTUP MOUNT f & Sead, SQL> ALTER DATABASE DATAFILE ‘/disk1/ofatiata/DEMO/rbsdatiO1 abe’ OFFLINE; Soi> ALTER DATABASE PBN si (you need ty to create temporary rolback segmgits in angiheP tablespace to process the running application users) : SQL> RECOVER DATAFILE 5; (Fil of the loGtrosdataO1 dbf data file) SQL> ALTER DATABASE DATAFIZE 5 ONLINE (tt you check the status ofthe rol back seorents thét'are treated in RoLaAACK_DATA tablespace sill it shows needs recovery) SoL> ALTER ROLLBACE SEGENT RBS? onthe; OBSERVATION: In this tesl, before we commitiag the transaction, we shut dovn the database with the ABORT ‘option, This means that te fllback seiment's yansacton table will tow show that the transaction is active. Now hor the database opan: Obl eannot ead Ts UGE Because recovery has finishes the rol forward but not the rl back of uncommitted transactions. This means that Oracle cannot determine wether the row we have inserted i committed or rolled back ‘This is be¢quse we have taken the data fies that contain the rollback segments offing Once we have finished dafafleRablespave recovery, the ralbeck segments are stil in NEEDS RECOVERY. At this point, we nged to brngallhevollback segments online using the alter rollback seguent command, 27.8. CASES # Database Crash During Hot Backups On Friday afternoon iil taking hot backups, the machine crashed, bringing the database down. Once the machine was booted, he tied tsar the dalabace and Oracla asked for media tecovery starting from log fle sequence number 840, The current onkne lg fle hed sequence number 55, which meant hat abou 25 logfiles needed to be {applied before the database coud be opened SOLUTION: Oracle gives the DBAs the abilty to end the backups of the date files that are in hot backup mode by Using the ALTER DATABASE DATAFTLE ‘file name’ END BACKUP command. You stil need to apply recovery ‘when the database crashes while taking online backups. EXAMPLE : SQL> CONN /AS SYSDBA SQL> STARTUP SQL> ALTER TARLESPACE TEST BEGIN BACKUP; § cp /diski/oradata/DEMO/tost01 dbf /di sk} /oradate/DEMO/BKUP SQL> DELETE FROM TEST WHERE ROWWUM ALTER SYSTEM SWITCH LOGFILE: wm wilsiresoft com Wishice Sofware Technologies Rev. Dt 27-Apr-08 hr 2761-22141 5577-2214 Version 4 Oracle 109 - Backup & Recovery Scenarios (fof 4) Page 86 0203, : Wi Daya SQL> SHUTDOWN ABORT Now we can perform two methods. The first method involves attempting to open the database with the current data fla, test01.dbf. The second method involves replacing the current data fle, tesi01 dbf, with the backup version and performing recovery. 27.8.1. Method 1: Using the current data file SQL> STARTUP MOUNT SQL> ALTER DATABASE DATAFILE ‘/diskl/oradata/DEMO/tost01.dbf’ END BACKUP; SQL> ALTER DATABASE OPEN; 27.8.2. Method 2: Using the Backup Data File § op /disk1 /oradata/DEMO/HBKUP/tost01.dbf /diski/oradata/DEMO SQL> STARTUP MOUNT ra SQL> ALTER DATABASE DATAFILE ‘/disk1/oradata/DEMO/test01 dbf, END BACKUP; SQL> RECOVER DATABASE; SQL> ALTER DATABASE OPEN; é OBSERVATION: When a tablespace is in hot backup mode, only some data struct headers, if multiple data files exist for that tablespace) are updated, while are ine dafa fle header (or For example, if an update is done on a table in this dafa file, the up ‘done, the checkpointed at SCN value is not written to the fle header. backup, Oracle really needs to update only the file header and nof the ct database. oe is not Blocked. at if a cr ia checkpoint is ‘oceuts during a hot Tile while opening the x if you want to know if any data fles are in hot backup mee, use We VSBACKUP view, when the status says ACTIVE, then the fe isin hot backup mode. we, 2 4 3 27.9. CASE 9: Recovery Through RESETLOGS PROBLEM: We take regular cold backups of the, databaté. Figure 1.1 Shows the time line and various events that ‘occurred in a sequential order, The log sequence numbers atvarious times are pointed out as well. [At point A, we have a taken a cold backup ofthe datsbidsl and epéhed the database for normal operation. At point B, 2 media failure occurred and he lost all the ogine 0g files. Since we doesrit multiplex the online og fs, we had 10 do incomplete recovery. So, we restored the database as @ point A and recovered the database using the recover database until eancel command. We applied ;ecoyety untl the last archive log fie and started up the database with RESETLOGS option at point & As shown in figité’41, the current log sequence number was reset to 1 again at point B Time Current log seq no. a 2 ean 2 3 FIGURE 1.4. Database events at various points in time ‘After a few days (at point C), another media failure occurred and we lost data file 5, All the oniine log fles and the ‘control fles were intact, so we restored the backup data fle for file 5 from point A and tried to do recovery. Oracle complained that data file 5 is from a point before B. we tiled to restore the backup contro! file and recover the database. This time, Oracle complained that file 1 is fram a point after B. Know we decided to restore all the data files, ‘and the control file from the cold backup ((com point A) and tried to do recovery again, Recovery went fine until point B, but we couldn't go past point B, since Oracle didn't recognize the fog files after point B. if we Couldn't recover up to point C, we would lose all the data that we had inserted from point & to point C. CAUTION: This is not an alternative for not backing up your database after a RESETLOGS! This method should be Used only in emergencies! wv. ishiresoftcom _Wiehite Sofware Technologios Rey. DE 27-Apr-08 "Ph, 2761-2214 | 5572214 Version: 4 ew Oracle 108. Backup & Recovery Scenarios (1 of 4) age 87 of 203 Wa:3- Day: 44 SOLUTION: This is especially useful when there is an outage prior to successfully backing up your database after a RESETLOGS. Oracle Support Services recommends that a backup be taken after a RESETLOGS; however, this feature provides a workaround for customers who cannot take the time to do a cold backup immediately after doing recovery with RESETLOGS. This feature should only be used under the following conditions: Oracle versions 7.3.9 and higher. = Previous recovery with RESETLOGS has been successful + No consistent backup after the RESETLOGS is present. = Acconsistent backup (cold or hot) prior to RESETLOGS is present. * Contra file after the RESETLOGS is present. = Allarchive log fles and online redo logs are present for recovery 1 you do not have any backups alter point A, then recovery is a bit complicated, as you,need to find out the exact ‘SCN (at point 8) at which RESETLOGS was done. mn Ifthe current control file (any control file after point B) is available, it is possible tovise the Backup taken before the RESETLOGS (at point A) and do the following! ey 2. 1. Find the SCN immediately before the database wos opened with RESETLOGS, The SCN is ported in the fio og just before the database is opened. Look or RESETLOGS afer incomplete tecovesy UNTIL CHANGE oven or RESETLOGS ater compete recovery thro ete "You shouts aso query this information from any controle that is valid after the RESETLC ‘the folowing query: SQL> SELECT RESETLOGS CHANGER - 1 FROM VSDAEABASE; game number. You will be recovering the database to this SCN. , 2, Shotdown the database. (Atpoint ©) e 3. Copy the curcent conta! fle toa safe lacatiog (You must havea copy'of the control file that was taken ater the RESETLOGS was performed — it does no! Be the eure conto! il). 44. Restore whale database and the contzoFfe from thie backups before tne RESETLOGS (point A of igure 1.1) 5. Recover the database using the cormand “ SQL> RECOVER DATABASE USING BACKUB EONTAOLETLE UNTIL CHANGE sssoox {Where »oo00ex is the SCN found in step 6. Shut down the database ‘ 7. Gopy the contol fle fom afte RESETLOGS {6 allocations in the CONTROL. FILES parameter inthe initora ee 8. Start up mount the database. 9. Use the appropiate recover database command and recover normally, Oracle should now ask for archive Jog sequence numer 1 HINTS: + Riv take a backup of your controle after RESETLOGS + Always back up all archive gs before attempting this operation. Dangers: It is possibie'{but not likely) that you may have conflicting archive log sequence numbers ( the same og sequence number from before the RESETLOGS point and after the RESETLOGS). You must be very careful not fo ‘ovenwmite one with the other, especially if they ere not backed up. 27.10. CASE 10: Creating Data Files PROBLEM: On @ Monday afternoon, while running an application, we got en Oracte error saying that there is no ‘more space in a specified tablespace. We then added a data file to that tablespace. Since the application does a fot (Of DAML operations and modifies a lol of fables, he dacided to wait until the application finished so that he could take @ Backup of the data fla he just added. On Friday morning, a media failure occurred, and we last the new data file we had added on Monday. We then realized that we forgot to take a backup of the data file on Monday. We could take the éle offine and start up the database, but we could lose a lot of data that the application had inserted into that data file. We could restore from the backup and roll forward, but this wouldnt work because the backup doesn't have the new data file we added on Monday. ve ashiresoftcom Wilshire Sofware Technologies Rev. Dt 27-Apr-05 Ph: 2768-2214 15577-2214 Version 4 oracle 109 - Backup & Recovery Scenarios (1 of 4) Page 88 of 203 e wk: 3-Day: 4.1 SOLUTION: This is a perfect scenario for re-creating the data file, To re-create the data file, we need the current control fie ora backup contal file that recognizes the new data file that was added on Monday. Next, all the archive {oq fies and online log fies need to be avaliable. All ve need to do is mount the database and issue the ALTER DADABASE CREATE DATAFILE command to re-create the data file. Once the file is created, we need to apply the redo (rall foward) from the time the file was created to the present time. TEST: SQL> ALTER TABLESPACE USERS ADD DRTAFILE ‘/diski/oradata/D8M0/aser02.cbf" SIZE 10M; ‘sgu> INSERT INTO TEST1 VALUES (222, ABCD); SQL> ALTER SYSTEM SWITCH LOGFILE: SQL> ALTER SYSTEM SWITCH LOGFILE; 3 em /disk1/oradate/DEMO/user02 .dbé Know we have to recover user02.ab file sou» niTPR DAOMAASE COENUE DMEAFTIS|*/diabi/oredata mmflner@. db SQL> RECOVER DATAFILE \/diskl/oradata/DENO/user02 dbf f=) OBSERVATION: The alter database create datafite command expects the Ui of @ coil le that hes the fle entry forthe datafile tobe re-created, Its therefore important to havé one. the fooling: + The current control file. && 7 . Tre current con) ates the ls ent forthe data af bo ape is pedns you should take a acaap oft conte le immediately afer the Schema chéne. ep >a Also, note inthis test thatthe AUER DATABASE CREATE DAAFILE Command adualy creates the data fo for you at the OS level, and the RECOVER DATAFILE command dads the change'from the redo log file and applies them to the data books. eS Se ‘Oracle 109 - Recovery Matic (1 of #) 28. Recovery Matrix Every Oracle Database could be running in any of the two modes: 4, NOARCHIVELOG Mode 2. ARCHIVELOG Mode Before we move further, let us understand two terms: “+ Restore: Bring back the lost fles from the most recent backup, + Recover: Applying the archive logs on the restored fies. If the Database is operating in NOARCHIVELOG Mode, the only option isto restore the most recent full backup and redo all the work performed after taking the backup. It the Database is operating in ARCHIVELOG Mode, several recovery options are possi file being lost. ‘Again, Recovery could be Complete or Incomplete “Complete Recovery results due to loss of any Datafle and could be performed Online: down). + Online Complete Recovery can be performed, wheh we loose 3 + Offline Complete Recovery can be performed, when We k Incomplete Recovery results due to loss of current online log or E Gifline (vith DB down) and we need to open the Database wi Page 69 of 203 WK: 3-Day 42 depending on the type of { Fontine [arcived [oon |swo oat ries (Rtas ea’ Icon onctusion Tbkup) 2 v x lincomplete [Restore + Recover until the last | es | 3 TTA [onine eompice Restore & Recover ost tates of Ron ytem Taterpaces }4 x q ¥ Y lomine [Complete |Restoze & Recover all the Datailes | ante te Rese Semnindo bespacts Unda 5 - Vv [Offline |Incomplete If all the members of a group are lost 6 v Vv x loftine [Could be — |Complete, if you recreate the ct! file. | Coe ears Ryo recover tom Dockop ee” fen te 7 A TPT oitine Preamps fs bon onto as & | Icontrol files are lost Note: In al the above cases we assume that we have a valid Physical Backup (Cold or Hol) and all the archive logs that got generated after taking the backup. ‘Oracle 10° - Upgradation Page 199 of 203, Wk: Day: 5 58. Upgradation to Oracle 10g Oracte Databases can be upgrades from one versiontelease to a higher versionvrelease to: + Use the new features ‘+ Tobe in @ supported database version. Oracle usually announces the de-support data for a DB Version several month ahead so that we ean play and test Database upgradation, This document provides @ generic approach to upgrading to Oracle 10g from order versions without any specific reference to the underlying operating system, Oracle 10g has four upgrade options; * Method 1 - Use the Database Upgrade Assistant (DBUA) se + Method 2 ~ Manual upgrade by running oracle supplied scripts $ * Method 3 ~ Using the exportimpor utilities * Method 4 — Using the SQL*Plus COPY/CREATE TABLE AS commands. © Before we upgrade database using any of the above methods, wo shotl@onderst Upgrade process which are outlined below. Step 1: Prepare to Upgrade Become familiar with the features ofthe new oracle DB. fog Faease + Determine the upgrade path tothe new oracle DB 1 + Choose an upgrade method {_Sheese an oct home deter forthe new race Date 100 ele + Develop a Testing Plan, A Step 2: Test the Upgrade Process / ‘ Perform a tst upgrade on a est DB. The test upgii’Bhould beonducted in any envionment created for testing {and should not nerfae withthe actual preculon BE Step 3: Test the UpgradesTest Database. + Perfoim tests on thetfests on te test OB afd onthe test DB that was upgraded + Compare resus noting anomalies betwen test results on the test DB & onthe upgraded DB. * Investigate walys to correetany anomialies and there implement the corrections, until the test upgrade is ‘completely succesful anc works with any required applications Step 4: Prepare and Preserve the Production Database ‘+ Pfepare the convent préductions DB as appropriate to ensure that the upgrade to the new oracle Database 410g release willbe successful * Schedule'ttie. downtime required for backing up and upgrade the production DB. Perform a full Backup of the current productions DB. Step 5: Upgrade the Production Database * Up grade the production DB to the new oracte 10g release * After the upgrade, perform a full backup ofthe production DB and perform the post upgrade tasks. Step 6: Tune and Adjust the New Production Database ‘+ The new oracle production DB should perform as good as, orbetter than, the DB prior to the upgrade. + Determine which features of the new release we want to use and update our application accordingly, + Develop new DB administration procedures as needed ‘Oracle 10° - Upgradation Page 200 of 203, Wi: 6-Day: 5 Step 1 Prepare to upgrade 1 Step 2 ‘Test the upgrade process t Step 3 Test the upgraded Test DB. Step4 Prepare & Preserve the production DB. sins vigsesanatonoe Pe Step 6 Tune & Adjust the New Production DB Oracle 109 provides a utitf’ecipt —uittlO2i sl, to-Berform preupgade validation on the DB to be upgraded. We can find the script in the adainistration scripts directofy (SORACLE-HOME/rdbms/admin). The utlu102i.sql script needs to be run as SYSDBA befote we plalkon porforifing @ manuel upgrade. I fs preferred to copy thin senso a temporary folder and run it after spodling the output toa file. We must run this scipt on the DB to be upgraded. ‘The DBUA automaticaly rungne sertas part of ypdtade process, + Check6:B Compatibilt Verifies the Fade log filesize is at least 4 MB + Estimatos the time for upgrade + Checks for obsolete & deprecated parameters * Finds all the components installed * Finds te default tablespace for each DB component schema * Checks the instled DB options * Checks the DB Character set and natural character set are supported in oracle 109. Once the scrip is done with the execution open the spooled file and check-out or the corrections tobe taken before actualy performing the upgradation. The sposted fle gves various information ike for exemple if the current Redoiog fe size are adequate for the upgradation or not and also on the sizes of the various SGA memory components and much more. Note: The minimum redologii size in oracle DB 10g is 4 MB. ve waishiesoR.com Wilshire Sofware Technologies Rov. Dt 27-Apr-08 Ph: 2761-2214 5577-2214 Vetsion: Oracte 10°- Upgradation Page 201 of 203 Wk:6- Day: 5 58.2. Performing the Upgrade 58.2.1. Method 1: Using DB UA We can perform a direct upgrade of an oracle DB to oracle 10g by using oracle’s GUI interface, the DBUA. The DB UA willbe invoked by the OUI when instaling oracle 10g software if it finds any executing oracle DB in ‘Tetcloratab’ In case of Linux, or in the windows Registry in case of windows platform the DBUA can also be invoked as a sland. alone too! after the installation of the Oracle 10g Software. ‘On UNIX platforms, we can invoke the DBUA by using the command 'DBUA’ on windows platform it can be invoked by choosing Start > Program Files > Oracle Configuration 2 Migration tools > Database upgrade Asst. ‘The upgrade process is automated by DBUA, including the preupgrade steps. The following are some of the OBUA features and their advantages: J + Prcuth pid nite ected das lense sped tet * Runs tne proupgrade validation and denies the options tobe upgraded. efor adjustments Checks for disk space & tablespace requirements * Updates obsolete initialization parameters. . p *+ Includes an options to backup the database prior to upgrade, + Shows uparade progress & writes detailed trace and log + Disables archiving of the Database during upgrade.» ‘Includes an option to recompile invalid objects afteculpgrade. * Shows summary page prior to upgrade and after the upatade * Able to upgrade ali nodes ofa Database in RAC * Removes the Database entry from the lsteherbra flegf the old’ Database and add it to listener ora of the new Database. , Note: We can also invoke the OBUA in contfnand-line modeWe can specily several parameters with the command dbua, douash shows the help information. Ei ‘We can manually upgrade the“Database by running sefipts using the SQL‘Plus Utility. Though manual upgrade brovdes us wih more cont the proces sor te involves are works ana cold ako ean Oracle 10 supports tale Rparace SRatoba rom the olowng release: * Oracle 8 Releasé8.0.6 "Oracle 8i Release 6.1.7. % + Orace& Release 001 + Orgies Reeeeso20 \¥a direct uogiade is not supported from the release number of our DB, then we must fist upgrade our Dalabase to an intermediate ofaele telease, The database then can be upgraded from this intermediate release to the now aracle DB 10grelease. “3 For example, f our current release is 8.1.6, then we need to first upgrade to release 8.1.7 using the instructions in oracle 61 migration for release 8.1.7. The release 8.1.7 DB can be upgraded to the new oracle DB 104. To manually upgrade the DB, follow these steps. ‘+ _ Install the Oracle 10g release software only, into anew ORACLE HOME location. Do not select ‘create database’ options during installation * Use 2 cold backup of existing DB which is of a order release connect fo the database and run the sevipt Lulu 102i.sql to determine the preupgrade tasks to be completed, (Please refer to sections ‘validating the DB. before upgrade’ ofthis document) * Resume the redolog files if they are smaller than 4MB, ‘+ Adjust the size ofthe tablespaces where the dictionary objects are stored. + Perform a cold backup ofthe database, * Shutdown the database with any of the grateful methods, \Wistire Sofware Technologies Rev. Dt 27-Apr 06 Ph: 2761-2214 (5877-2214 Version: 4 (Oracle 10° Upgradation age 202 of 203 WK: 8 Day: 5 * Copy the parameter fle Gritor. or spe) and password fie fom the old oracle home directory tothe oracle 10g home directory * Adjust the intra fie by setting Cowentrszs parameler tothe fe 10.2.0 and also adjust the SGA meméry components tothe minimum requited values. Make sure all the environment variables are set to corectly reference the oracle 10g Home. + Use the SQL+ plus, and correct the DB using sYspBa privilege and start the instance by using the STARTUP. ‘UPGRADE mode. 8 sqlplus * ‘/as sysdba’ SQL> STARTUP UPGRADE ‘Create the sySaux tablespace with the following attributes. © ONLINE 9 PERMANENT © READ WRITE 0 EXTENT MANAGEMENT LOCAL, © SEGMENT SPACE MANAGEMENT AUTO The syntax could be as follows : ‘SQL> CREATE TABLESPACE. SYSAUX DATAPILE ‘disk1 /oradata/ORChPsysaux01, EXTENT MANAGEMENT LocaL SEGMENT SPACE MANAGEMENT AUTO; Run the upgrade script from the $oRACLE-HoM /velt fname of the upgrade script varies, Refer tothe following table to choose the correct. sf Old Release Run Script > (Oracle 80.6 120800060.sqf (Oracle 81.7 0801970 Sq (Oracle 9.0.1 [20900010 sq) : Oracte 9.2.0 juoso2do0sat if wo got any errors dur the upgrade script exedutes during the upgrade soript executes re-execute the sotplatr bara nagror ee ae Fer example, uplade an orl 2.0 Oo oracle 109 we must run 10902000. SQL>seoot, uBgradestog 7 Shi>tSonAGLEe Hows fedborne amintows090200 sah Soostooe ork ee Check the'gpoo!file'& verify thal the packages and procedures are compiled successfully. Correct any probioms ap fin i fle and rerun the aperprat upgrade script necessary + Rimpost-upgrade status script utlu1025.sql. Specifying the TEXT option to see if all the components are Pept erty S01> (S0:Wircbms/adnin/utiul025. 690, TEXT + Shutdown the B84 Startup S0L> SEDONA ot> suanue ifwe encounter a message isting chsces int parameters wen we start he DB, then remove the remove De ell ee 4 + Rnutp sao re-compute any remaining stored PLSQL and Java code S9t> ¢90.M/sdbms/acnan /aterp. ©) Vat that al packages are vad S0L> SELECT count|(*) from DBA OBJECTS WHERE Statue = ‘ZAVALA; (Our 08 is now upgraded to the new oracle DB 10g release. Post Upgrade Tasks: + Backup the Database wir wilshiresoR.com ‘Wilshire Sofware Technologies Rev. Dt 27-Apr-08 Ph 2761-2214 / 5877-2214 Version: & PETS TESTE ED DB eer se Oracle 10%- Upgradation Page 203 of 203 WK:6- Day: 5 * Change the password for oracle supplied Database accounts ike DRSwMe, OUTLN + Migrate the pfile to spfile Gif needed) ‘Modify the listener confirmation file to point tothe new ORACLE_ HONE. 58.2.3. Method 3: Using EXP/ IMP Uti Upgrading a Database using the exportvimport method has the following advantages and disadvantages: ies: ‘= How long the upgrade process takes depends on the size of the DB. ‘+ For smalier D8's in non-upgrade-supported releases lke 8.0.6, 8.1.5, oF 8.1.6, i may be faster to perfor an ‘exp/imp rather than going through two upgrade processes, ‘+ Anew DB for oracle 10g needs to be created, so we need to double the amount af disk space required, + Gives an opportunity to create tablespace using the nev features of oracie 10g ‘= The import process can defragment data that would improve performance. Use the following steps to upgrade: 3. Take a full DB export ofthe existing DB (Older versions) using command: $ oxp systen/ file=full.dmp log-full.log full-y Use other options ofthe exp utility as appropriate. 4. Create a new 109 database with minimum tablespaces use the iiport uit to import the definition and dala from the dump file created in step 1 § imp syston/ file=full.dnp log-upgrade. Teg Fully Use ather option of imp ulility as appropriate. Her, wile importing we need take care that wet configu the pa FAK cACHE_s128 in nt ora parameter fr te non default abospaces, Otherwise, he gblespace ean fi fhe oder Version Database has tablespace of 2k 24, "6k and 32k Bs we kno tha the deaul ck size am Oracle 109 ise 5. Check the Log fle after the upgrade procass is ovr and if we come across any errors, correct the error {and impor that specified object only, Alternate Method: Use this method if we don't wishsfo go with the full DB export perform export for all objects SYSTEM using the OWNER option’of the export utity the application as 9 exp systom/sbassword>file-app.dmp logeapp.log owner=appl This has to be performed for allthe schertiag incase the DB is supporting more than on application. Once we are done with export on all the schemas of the order version OB, create a new Oracle 10g 08 with minimum requirements. Create the tablespaces-and,users that are present in order version of the DB manually. Now use the above created dump filas to import back into the appropriate schemas. Note: Here‘we need (0 take, of the dependences between the schemas if any and resolve then a5 per the business requirements, 58.2.4. Method'4: Upgrade using COPY / CREATE TABLE AS Commands ‘We can copy data from dhe oracle DB to anather using Database links. For examples, we can create new tables and fill the tables with data by using the INSER IN7O statement and the CREATE TABLE as Statement. Alternatively, we can also use the COPY command, ‘opying data and Expor/impart offer the same advantages for upgrading. Using either method we can defragment jata files and restructure the DB by creating new tablespace or modifying exisling tables or tablespace. In addition wwe can copy only specified DB objects or users Copying data, however, unlike Exporvimport enables the selection of specific rows of tables to be placed into the new 1B. Copying Data is good method for copying only point of a Database table. In contrast, using Exnor/impor, we can ony only entire tables, sw ulshiresot com Wishire Software Technologies Rev, Bt 27-Apr-06 Ph: 2761-22441 5577-2214 Version: 4 OR EER Drace “ip 2asey Manager Page at of 13 CHANNEL channel_id Specifies the case-sensitive name of 2 channel to use when creating packup sels. Use any name that is meaningful, for example cht or dev? © CUMULATIVE - Copies the data biocks used since the most recent backup at level n-t oF tower, where n ig an integer from 1 to 4, For exempls, in a cumuiative level 2 backup RMAN backs up all blocks used since the most recent level 4 or level 0 backup. « MAXSETSIZE = integer - Specifies a maximum size for 2 backup set in bytes (cefaul), iiopytes (K), megabytes (M), and gigabtyes (G). Thus, to limit @ Backup set to 3 MB, specty MAXSETSIZE = 3M, + HLESPERSET = integer. Specifies the maximum numberof input files in each backup sot If you sel FILESPERSET = n, then RMAN never inchidos more thar n files in a backup set © NOTBAGKED UP - Backs up only those files (ofthe files specified on the command) that RMAN has not backed up since the specified time. if SINCE TIME is not specified, then only those files thet have never been backed up will be backed up. since TIME = ' date string’ Spocifos the date afer which RMAN choud back up fles thet have no backups. The date_sting werSthor a date in the current NLS_DATE_FORMAT, of a SQL date expression such as ‘SYSDATE-1’ «DEVICE TYPE. - Allocates automatic channels for the specified device type only. 'BCKUP DEVICE TYPE DISK DATABASE: = INGLUDE GURRENT CONTROLFILE - creates 2 snapshot ofthe current control fle and places itinto oach backup set produced by this clause. = DELETE INPUT deletes the input fles upon successful creation of th copiion only when backing up archived logs, datattle copies, = FORMAT. - Specifies a filename to use for the backup piece. if you do not Specity # parameter, RMAN stores the backup pieces in a port-speciic directory (SORACLE_HOME/abs on UNIX). Soe Specifies the copy number of the backup piece within a set of duniexed backup pisces. %d__Specifies the name of the database. {2D Species the current day ofthe month fiom the Gregorian calondar ip formal DD. ‘MF Combines the DBID, dey, month, year, and sequence into a unique and repeatable generated name, ‘4M Specifies the month jn the Gregorian catendar in format MM ten Specifies the name of the database, padded on the right with x characters to feta iength of eight Characters. Specifies the plece number within the backup set Specifies the backup set number. Specifies the backup set time stamp, which is a 4-byte value derived as the number of seconds elapsec since a fixed reference time. %T Specifies tha year, month, and day in this format: YYYYMMOD. Su Specifies an 8-character name constituted by compressed represent ‘sot number and the time the backup set was created. {48 Specifies a convanient shorthand for %u_shp_%e that_ guarantees uniqueness ‘9 generated backup filenames. %Y Specifies the year in this format YYVY. tht Speci the '% character, For example, %¥4Y transiates tothe string FORMAT yng of the backup ‘Example 1: Backing Up a Database: This command backs up the datebase to tape and then becks up he ‘contro! fil that contains the record of the database backup’ "BACKUP DATABASE; BACKUP CURRENT CONTROLPILE Example 2: fee ean racte 10q-Recovery Manage ‘ SEP UNTIL TIm ‘gun 18 2006 16:32:36"; RESTORE CONTROLFISE TO */cmp/cf-tmp REPLICATE CONTROLEILE PROM '/tmp/of.emp! : STARTUP FORCE MOUNT; } Page 86 of 3 Example 4: Performing Incomplete Recovery by Using @ Backup Control Fite: Assume that both the database and archived ‘redo log 1234 wore lost due to 8 disk crash, Because you do not have incremental backups, you need to recover the database by using availabic archived redo logs. You do not need to restore ‘ablespace readonly! because thas, ot changed since log 1234 RON t SRT UNTIL SEQUENCE 1234 THREAD 1; # Recover database until log Sequence 1234 RESTORE CONTROLFILE TO */vobs/oracle/dbs/aft.£"; # Because you specified @ restore destination, manually replicate the RESTORE DATABASE SKIP TABLESPACE tomp!, readonlyt; RECOVER DATABASE SKIP FOREVER TABLESPACE temp: ALTER DRTABASE OPEN RESETIOGS; SQL "DROP TABLESPACE tenp! 'SQh "CREATE TABLESPACE tompl DATAFILR ‘/vobs/orscle/dbs/taspl.f' SIZE 10m ‘TEMPORARY" ; Example 5: Performing Incomplate Recovery Untl a Log Sequence Number: Example This example assumes that log sequence 4234 was lost dua to 2 disk creeh and the database neod tobe recovered by using avaible archived redo logs. eon ‘ SEU UNTTL SEQUENCE 1236 THREAD 1 RESTORE CONTROLFTLE TO "SORACLE_HOME/dbe/at1€' ; REPLICATE CONSROLPELE FROM." $ORACLE HOME /cbs/c£1.£" (AUIBR DATABASE YOUNT; RESTORE DATABASE, RECOVER DATABASE; # recovers through log 1233 SQL "ALTER DATABASE OPEN RESESTLOGS" ; , Example 6: Performing Incomplete Recovery to @ Speciiod SON: This example recovers the database unti a speciied SCN’ SEARTUP MOUNT? ROW t RLLOCAE CHANNEL chI TYPE abt RESTORE DATABASE; RECOVER DATABASE UNTIL SCN 1000; # recov SQL "ALTER DMPABASE OPEN RBSESTLOCS" , 77, RELEASE CHANNEL: To release 0 channe! while maintaining the connection tothe target database instance. Speci the channel name with the same iertifer used inthe ALLOCATE CHANNEL command. this command is optonal because RMAN automaticaly releases al channots alocated when the RUN command terminates Shrough Sc 999 Example ts Releasing a Channel: This example makes three identical beckup sets of dalafiles 1 through 4 to tape with channel cht, then releases it, RMAN then makes three identical backups of datafile 5 and 6 to tape with channel ch2 and then releases it ROM SET BACKUP COPIES = 3;

You might also like