Top Banner
PREPARED BY CHOWDARY 1_RMAN_SETUP 1 - RMAN Setup and Configuration RMAN Setup and Configuration ---------------------------- Configure the Database for RMAN Operations ------------------------------------------ Set Up the Database User in the target database ----------------------------------------------- create user backup_admin identified by backup_admin default tablespace users; grant sysdba to backup_admin; Creating the Recovery Catalog ----------------------------- Creating the Recovery Catalog User ---------------------------------- create user rcat_user identified by rcat_user default tablespace users; grant connect,resource,recovery_catalog_owner to rcat_user; Creating the Recovery Catalog Schema Objects -------------------------------------------- Step 1. Connect to the recover catalog with RMAN: rman catalog=rcat_user/rcat_user@reco Step 2. Issue the create catalog command from the RMAN prompt: create catalog; Register your database in the recovery catalog ---------------------------------------------- Step 1: Using RMAN, sign into the database and the recover catalog at the same time ORACLE_SID=HMDEV; export ORACLE_SID rman catalog=rcat_user/rcat_user@RECO target=backup_admin/backup_admin or ORACLE_SID=RECO; export ORACLE_SID rman catalog=rcat_user/rcat_user target=backup_admin/backup_admin@HMDEV Recovery Manager: Release 9.2.0.1.0 - 64bit Production Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. connected to target database: RECO (DBID=1308910273) connected to recovery catalog database Step 2: Register the database with the recovery catalog RMAN> register database Errors Faced ------------------- Delete the recovery catalog database, after somedays created a new database, but was not able to take backup, I was getting ora-1580 error Solution - unregister database select * from rc_database; execute dbms_rcvcat.unregisterdatabase (db_key, db_id)
28
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

1_RMAN_SETUP1 - RMAN Setup and ConfigurationRMAN Setup and Configuration----------------------------Configure the Database for RMAN Operations------------------------------------------Set Up the Database User in the target database-----------------------------------------------create user backup_admin identified by backup_admin default tablespace users;grant sysdba to backup_admin;Creating the Recovery Catalog-----------------------------Creating the Recovery Catalog User----------------------------------create user rcat_user identified by rcat_user default tablespace users;grant connect,resource,recovery_catalog_owner to rcat_user;Creating the Recovery Catalog Schema Objects--------------------------------------------Step 1. Connect to the recover catalog with RMAN:rman catalog=rcat_user/rcat_user@recoStep 2. Issue the create catalog command from the RMAN prompt:create catalog;Register your database in the recovery catalog----------------------------------------------Step 1: Using RMAN, sign into the database and the recover catalog at the same timeORACLE_SID=HMDEV; export ORACLE_SIDrman catalog=rcat_user/rcat_user@RECO target=backup_admin/backup_adminorORACLE_SID=RECO; export ORACLE_SIDrman catalog=rcat_user/rcat_user target=backup_admin/backup_admin@HMDEVRecovery Manager: Release 9.2.0.1.0 - 64bit ProductionCopyright (c) 1995, 2002, Oracle Corporation. All rights reserved.connected to target database: RECO (DBID=1308910273)connected to recovery catalog databaseStep 2: Register the database with the recovery catalogRMAN> register databaseErrors Faced-------------------Delete the recovery catalog database, after somedays created a new database, but was not able to take backup,I was getting ora-1580 errorSolution - unregister databaseselect * from rc_database;execute dbms_rcvcat.unregisterdatabase (db_key, db_id)

Page 2: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

RMAN Backup StepsRMAN Backups - Online Database Backups - SolarisRMAN Backups - Online Database BackupsStep 1. Start RMANORACLE_SID=HMDEV; export ORACLE_SIDrman target=backup_admin/backup_admin@HMDEV catalog=rcat_user/rcat_user@RECOStep 2. Configure the necessary parameters.configure controlfile autobackup ON;configure controlfile autobackup format for device type disk to 'd:\backup_test\%F';configure channel device type disk format '/crmg/home/oracle92/rman_backups/bkup_%d_%s_%p';(The below step is optional, if you want to store the backups in another server you need tosetup NFS)Step 3. Set NFS mount for /crmg/home/oracle92/rman_backups - SolarisOn the Server where u want to copy the filesvi /etc/dfs/dfstabshare -F nfs -o rw=190.2.12.113 -d "share" /crmg/home/oracle92/rman_backups/etc/init.d/nfs.server stop/etc/init.d/nfs.server startOn the database servermkdir /rman_backups# dfshares 190.2.12.114RESOURCE SERVER ACCESS TRANSPORT190.2.12.114:/crmg/home/oracle92/rman_backups 190.2.12.114 - -mount 190.2.12.114:/crmg/home/oracle92/rman_backups /rman_backupsStep 4. Start the BackupSee down for incremental backupsRMAN> backup database plus archivelog;Starting backup at 29-APR-04current log archivedallocated channel: ORA_DISK_1channel ORA_DISK_1: sid=94 devtype=DISKchannel ORA_DISK_1: starting archive log backupsetchannel ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1 sequence=29 recid=1 stamp=523805849input archive log thread=1 sequence=30 recid=2 stamp=523824461input archive log thread=1 sequence=31 recid=3 stamp=523862791input archive log thread=1 sequence=32 recid=4 stamp=523967671input archive log thread=1 sequence=33 recid=5 stamp=524071120input archive log thread=1 sequence=34 recid=6 stamp=524175724input archive log thread=1 sequence=35 recid=7 stamp=524280582input archive log thread=1 sequence=36 recid=8 stamp=524386949input archive log thread=1 sequence=37 recid=9 stamp=524492739input archive log thread=1 sequence=38 recid=10 stamp=524597129input archive log thread=1 sequence=39 recid=11 stamp=524686567input archive log thread=1 sequence=40 recid=12 stamp=524686766input archive log thread=1 sequence=41 recid=13 stamp=524686810channel ORA_DISK_1: starting piece 1 at 28-APR-04

Page 3: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

channel ORA_DISK_1: finished piece 1 at 28-APR-04piece handle=/rman_backups/01fkc5es_1_1 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:02:16Finished backup at 29-APR-04Starting backup at 29-APR-04using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetincluding current SPFILE in backupsetincluding current controlfile in backupsetinput datafile fno=00001 name=/oracle/oradata/HMDEV/system01.dbfinput datafile fno=00002 name=/oracle/oradata/HMDEV/undotbs01.dbfinput datafile fno=00011 name=/oracle/oradata/HMDEV/T_HEALTH.dbfinput datafile fno=00005 name=/oracle/oradata/HMDEV/example01.dbfinput datafile fno=00010 name=/oracle/oradata/HMDEV/xdb01.dbfinput datafile fno=00006 name=/oracle/oradata/HMDEV/indx01.dbfinput datafile fno=00009 name=/oracle/oradata/HMDEV/users01.dbfinput datafile fno=00003 name=/oracle/oradata/HMDEV/cwmlite01.dbfinput datafile fno=00004 name=/oracle/oradata/HMDEV/drsys01.dbfinput datafile fno=00007 name=/oracle/oradata/HMDEV/odm01.dbfinput datafile fno=00008 name=/oracle/oradata/HMDEV/tools01.dbfchannel ORA_DISK_1: starting piece 1 at 28-APR-04channel ORA_DISK_1: finished piece 1 at 28-APR-04piece handle=/rman_backups/02fkc5j6_1_1 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:02:57Finished backup at 29-APR-04Starting backup at 29-APR-04current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting archive log backupsetchannel ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1 sequence=42 recid=14 stamp=524687130channel ORA_DISK_1: starting piece 1 at 28-APR-04channel ORA_DISK_1: finished piece 1 at 28-APR-04piece handle=/rman_backups/03fkc5or_1_1 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:02Finished backup at 29-APR-045) List backup6) show all7) report obsolete; - to reports no of backup copiesdelete obsolete;

RMAN Backups - Incremental RMAN Backups - Cumulative----------------------------------------------------Incremental RMAN Backups - CumulativeDay Level CommandSun 0 backup incremental level=0 database plus archivelog delete input tag='qcdb level 0backup (Sun)'

Page 4: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

Mon 2 backup incremental level=2 cumulative database plus archivelog delete input tag ='qcdb level 2 backup (Mon)'Tue 2 backup incremental level=2 cumulative database plus archivelog delete input tag = 'qcdblevel 2 backup (Tue)'Wed 1 backup incremental level=1 database plus archivelog delete input tag = 'qcdb level 1backup (Wed)'Thur 2 backup incremental level=2 cumulative database plus archivelog delete input tag ='qcdb level 2 backup (Thur)'Fri 2 backup incremental level=2 cumulative database plus archivelog delete input tag = 'qcdblevel 2 backup (Fri)'Sun 0 backup incremental level=0 database plus archivelog delete input tag = 'qcdb level 0backup (Sun)'RMAN> backup incremental level 0 database plus archivelog delete input tag='qcdb level 0backup (Sun)';Starting backup at 07-MAR-05current log archivedallocated channel: ORA_DISK_1channel ORA_DISK_1: sid=23 devtype=DISKRMAN-00571:RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ==========================================================RMAN-03002: failure of backup command at 03/07/2005 11:54:23RMAN-06059: expected archived log not found, lost of archived log compromisesrecoverabilityORA-19625: error identifying file D:\ORACLE\ORA92\RDBMS\ARC00028.001ORA-27041: unable to open fileOSD-04002: unable to open fileO/S-Error: (OS 2) The system cannot find the file specified.change archivelog all crosscheck;RMAN> change archivelog all crosscheck;released channel: ORA_DISK_1allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=23 devtype=DISKvalidation failed for archived logarchive log filename=D:\ORACLE\ORA92\RDBMS\ARC00028.001 recid=18stamp=551016351validation succeeded for archived logarchive log filename=D:\ORACLE\ADMIN\QCDB\ARCHIVE\ARC00057.001 recid=33stamp=552228124RMAN> backup incremental level 0 database plus archivelog delete input tag='qcdb level 0backup (Sun)';Starting backup at 07-MAR-05current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting archive log backupsetchannel ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1 sequence=57 recid=33 stamp=552228124input archive log thread=1 sequence=58 recid=34 stamp=552303737

Page 5: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

input archive log thread=1 sequence=59 recid=35 stamp=552304073input archive log thread=1 sequence=60 recid=36 stamp=552304080input archive log thread=1 sequence=61 recid=37 stamp=552304171input archive log thread=1 sequence=62 recid=38 stamp=552311463input archive log thread=1 sequence=63 recid=39 stamp=552311662input archive log thread=1 sequence=64 recid=40 stamp=552312680channel ORA_DISK_1: starting piece 1 at 07-MAR-05channel ORA_DISK_1: finished piece 1 at 07-MAR-05piece handle=D:\QCDB_BACKUP\BKUP_QCDB_13_1 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:27channel ORA_DISK_1: deleting archive log(s)archive log filename=D:\ORACLE\ADMIN\QCDB\ARCHIVE\ARC00057.001 recid=33stamparchive log filename=D:\ORACLE\ADMIN\QCDB\ARCHIVE\ARC00058.001 recid=34stamparchive log filename=D:\ORACLE\ADMIN\QCDB\ARCHIVE\ARC00059.001 recid=35stamparchive log filename=D:\ORACLE\ADMIN\QCDB\ARCHIVE\ARC00060.001 recid=36stamparchive log filename=D:\ORACLE\ADMIN\QCDB\ARCHIVE\ARC00061.001 recid=37stamparchive log filename=D:\ORACLE\ADMIN\QCDB\ARCHIVE\ARC00062.001 recid=38stamparchive log filename=D:\ORACLE\ADMIN\QCDB\ARCHIVE\ARC00063.001 recid=39stamparchive log filename=D:\ORACLE\ADMIN\QCDB\ARCHIVE\ARC00064.001 recid=40stampFinished backup at 07-MAR-05Starting backup at 07-MAR-05using channel ORA_DISK_1channel ORA_DISK_1: starting incremental level 0 datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetincluding current controlfile in backupsetinput datafile fno=00019 name=D:\ORACLE\ORADATA\GOVT\T_HEALTH01.DBFinput datafile fno=00001 name=D:\ORACLE\ORADATA\GOVT\SYSTEM01.DBFinput datafile fno=00013name=D:\ORACLE\ORADATA\GOVT\HM_CORE_TBL_TB01.DBFinput datafile fno=00002 name=D:\ORACLE\ORADATA\GOVT\UNDOTBS01.DBFinput datafile fno=00011 name=D:\ORACLE\ORADATA\GOVT\HM_REF_IDX_TB01.DBFinput datafile fno=00015 name=D:\ORACLE\ORADATA\GOVT\HM_REF_TBL_TB01.DBFinput datafile fno=00005 name=D:\ORACLE\ORADATA\GOVT\EXAMPLE01.DBFinput datafile fno=00010 name=D:\ORACLE\ORADATA\GOVT\XDB01.DBFinput datafile fno=00006 name=D:\ORACLE\ORADATA\GOVT\INDX01.DBFinput datafile fno=00009 name=D:\ORACLE\ORADATA\GOVT\USERS01.DBFinput datafile fno=00003 name=D:\ORACLE\ORADATA\GOVT\CWMLITE01.DBFinput datafile fno=00004 name=D:\ORACLE\ORADATA\GOVT\DRSYS01.DBFinput datafile fno=00007 name=D:\ORACLE\ORADATA\GOVT\ODM01.DBFinput datafile fno=00008 name=D:\ORACLE\ORADATA\GOVT\TOOLS01.DBF

Page 6: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

input datafile fno=00012name=D:\ORACLE\ORADATA\GOVT\HM_USERS_IDX_TB01.DBFinput datafile fno=00014name=D:\ORACLE\ORADATA\GOVT\HM_CORE_IDX_TB01.DBFinput datafile fno=00017 name=D:\ORACLE\ORADATA\GOVT\HM_MQS_IDX_TB01.DBFinput datafile fno=00016name=D:\ORACLE\ORADATA\GOVT\HM_MQS_TBL_TB01.DBFinput datafile fno=00018 name=D:\ORACLE\ORADATA\GOVT\T_INDEX.DBFchannel ORA_DISK_1: starting piece 1 at 07-MAR-05

RMAN CommandsRMAN Backups - Configure/Backup/Report CommandsPersistant ConfigurationCONFIGURE command enables you to configure various backup, restore and recover parametesRetention Policy----------------RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 3;Establishes the number of backups files and control files you want to retainRMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

Establishes the number of days the backups are to be retained.The redundancy policy and the recovery window policy are mutally exclusiveAutomatic Channel Configuration and Allocation----------------------------------------------CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'd:\backups\bkup_%d_%s_%p';

CONFIGURE DEFAULT DEVICE TYPE TO DISK;CONFIGURE DEFAULT DEVICE TYPE CLEAR;Automatic Backup of Control Files--------------------------------BACKUP command INCLUDING CONTROL FILE;Backup Optimization-------------------CONFIGURE BACKUP OPTIMIZATION ON;Will cause Oracle to skip backups of files that already have identicalbackups on the device being backed up to.if it is ON, RMAN skips the files for which a backup already exists on the same device with thesame header status. The same header implies that no modifications where made to the data inthose files since the last backup. This feature is useful for archivelog backups; in this case thearchivelog files that are already backed up can be skippedAutomated Backups of the Control File and the Database Parameter File----------------------------------------------------------------------configure controlfile autobackup on;configure controlfile autobackup off;When autobackup of the control and parameter files is configured, the following rule apply:> The control file and the server parameter file will be automatically backed up with eachRMAN backup or copy command issued that is not included in a run block.> If a run block is used, the control files and parameter files will be backed up at the end of therun block if the last command is not backup or copy.

Page 7: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

RMAN> configure controlfile autobackup format for device type disk to 'd:\backup\contf\robt_%F'When this option is used, the Oracle RDBMS will automatically back up the control file duringdatabase structure changes that impact the control file.Number of channels------------------CONFIGURE DEVICE TYPE DISK PARALLELISM 2;CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT 'd:\backup\robt\backup_%U';CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT 'e:\backup\robt\backup_%U';

If you start an automated backup, two channels will be allocated to perform the backup in parallel.Excluding Tablespaces---------------------CONFIGURE EXCLUDE FOR TABLESPACE hr_tbsp;CONFIGURE EXCLUDE FOR TABLESPACE hr_tbsp clear;Size of backup set piece------------------------CONFIGURE CHANNEL 1 DEVICE TYPE DISK MAXPIECESIZE 100m;We are limiting channel 1 to create each individual backup pieceat a maximum size of 100mb. Note that this command does not limitthe overall size of the backup.MaxSize for entire backup set-----------------------------CONFIGURE MAXSETSIZE TO 7500K;CONFIGURE MAXSETSIZE CLEAR;Duplexed copies---------------configure datafile backup copies for device type disk to 2;Snapshot control file---------------------configure snapshot control file name to 'd:\oracle\backup\scontrolf';This file is a point-in-time copy of the database control file thatis taken during RMAN backup operations. This ensures that the backup is consistent to a givenpoint in time. Thus, if you add a tablespace or datafile to a database after the backup has started(assuming an online backup, of course) that tablespace or datafile will not be included in thebackupBackup Commands OptionsBackup of Archivelogs---------------------BACKUP DATABASE PLUS ARCHIVELOG;Restartable Backups-------------------BACKUP DATABASE NOT BACKED UP SINCE TIME 'sysdate - 7';Tags - Each backup in Oracle can be assigned a tag----RMAN> backup database tag = 'test backup'Limiting the size of a Backup Set---------------------------------RMAN> backup database maxsetsize=50m tag='test backup'

Page 8: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

Using this parameter we have limited the maximum size of the backup set to 50MB.This is handy if your tape has a size limit or if your disks can only handle datafiles that are acertain size.Modifying the Retention Policy for a Backup Set-----------------------------------------------backup database keep forever;backup database keep until time ='sysdate+180';Overriding the configure exclude command----------------------------------------backup database noexclude keep forever tag='test backup';If you want to ensure that RMAN back up these datafiles, you can include the noexcludeparameter in the backup command.Checking the Database for Errors with Backup Command--------------------------------------------------backup validate database;Scan the database for physical and logical errors without actually doing a backup.Skipping offline, Inaccessible or Read-Only Datafiles-----------------------------------------------------backup database skip readonly;backup database skip offline;backup database skip inaccessible;backup database skip readonly skip offline skip inaccessible;Forcing a Backup of Read only Datafiles---------------------------------------backup database force;Backing Up Datafiles Based on Their Last Backup TimeBacking up only newly added datafiles-------------------------------------backup database not backed up;Backing up files not backed up in a specific time period--------------------------------------------------------backup database not backed up sice time='sysdate -2';Checking for logical corruption during a backup-----------------------------------------------backup check logical database;backup validate check logical database;If you wish the backup to continue through a given number of errors, you need to set themaxcorrupt parameter first. This requires using a run block, as shown in this examplerun{set maxcorrupt for datafile 1,2,3,4,5,6,7 to 10;backup validate check logical database;}Making copies of Backups on our RMAN copier-------------------------------------------backup database copies=2;Capturing the Elusive Control File----------------------------------backup database device type disk include current controlfile;

Page 9: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

Set Command OptionsTo define settings that only apply to the current RMAN session.-To Display RMAN commands in the message log, use the set echo command- To specify a database's database identified (DBID), use the set DBID command. Certain setcommands can only be used within the confines of a run block.- The set newname command is useful if you are perfoming TSPITR or database duplication-The set newname command allows you to specify new database datafile names. This is useful ifyou are moving the database to a new system and the file system names are different. You needto use the switch command in combination with the set newname command.- Using the set maxcorrupt for datafile command enables you to define a maximum number ofdata block corruptions allowed before the RMAN operation will fail- Using the set archivelog destination command allows you to modify the archive_log_Dest_1destination for archived redo logs- Using the set with the until clause of the set command enables you to define a specific poing intime, an SCN, or a log sequence number, to be used during database point-in-time recovery- using the set backup copies command enables you to define how many copies of the backupfiles should be created for each backup piece in the backup set- Using the set command id setting enables you to associate a given server session to a given channel- Using the set controlfile autobackup format for device type command enables you to modifythe default format for control file autobackups.run{set maxcorrupt for datafile 3 to 10;set backup copies = 3;backup database;}If you wish to do a backup that creates two copies of each backup piece that is created, an youwant to allow for ten corruptions in datafile 3.Report CommandsREPORT OBSOLETE RECOVERY WINDOWS 7 DAYS;REPORT NEED BACKUP RECOVERY WINDOW 7 DAYS;LIST CommandsLIST BACKUPLIST BACKUP BY FILE;Other CommandsSHOW ALL;SHOW RETENTION POLICY;CROSSCHECK command to check if backup sets or file copies exist

RMAN - Duplicate DB on the same ServerDuplication to the same Server Using Disk BackupsStep 1. Build your auxiliary database directory structures:

Page 10: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

mkdir /oracle/oradata/aux1mkdir /oracle/oradata/aux1/archcd /oracle/adminmkdir aux1cd aux1mkdir pfile bdump udump cdumplsStep 2. Copy the target init.ora file to the auxiliary location.if your target database uses an spfile, you need to create a pfile from the spfile in order captureparameters to move overif you use an spfile at your target, enter the followingsql> connect / as sysdbacreate pfile='/oracle/admin/aux1/init.ora' from spfile;cp initprod.ora /oracle/admin/aux1/pfile/init.oraStep 3. Make all necessary changes to your aux1 init.ora file:db_name=aux1############################################ Diagnostics and Statistics###########################################background_dump_dest=/oracle/admin/aux1/bdumpcore_dump_dest=/oracle/admin/aux1/cdumptimed_statistics=TRUEuser_dump_dest=/oracle/admin/aux1/udump############################################ File Configuration###########################################control_files=("/oracle/oradata/aux1/control01.ctl")instance_name=aux1db_file_name_convert=('HMDEV','aux1')log_file_name_convert=('HMDEV','aux1')remote_login_passwordfile=exclusiveStep 4. Build your aux1 password fileStep 5. start the aux1 instance in nomount mode:ORACLE_SID=aux1;export ORACLE_SIDsqlplus /nologsql> connect / as sysdbasql> startup nomount pfile=/oracle/admin/aux1/pfile/initaux1.oraStep 6. Configure your network files for connection to aux1.After making any changes to your listener.ora file, be sure that you bounce your listener, or thechange will not take effectlsnrctl stoplsnrctl start

tnsnames.oraaux1 =(DESCRIPTION =(ADDRESS_LIST =

Page 11: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

(ADDRESS = (PROTOCOL = TCP)(HOST = 190.2.12.113)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = aux1)))listener.oraSID_LIST_LISTENER =(SID_LIST =(SID_DESC =(SID_NAME = PLSExtProc)(ORACLE_HOME = /oracle/product/920 )(PROGRAM = extproc))(SID_DESC =(GLOBAL_DBNAME = hmdev)(ORACLE_HOME = /oracle/product/920)(SID_NAME = hmdev))(SID_DESC =(GLOBAL_DBNAME = aux1)(ORACLE_HOME = /oracle/product/920)(SID_NAME = aux1)))Step 7. From RMAN, connect to the target and auxiliary instance and run the duplicatecommandORACLE_SID=HMDEV; export ORACLE_SIDrmanRMAN> connect target /connected to target database: HMDEV (DBID=289711392)RMAN> connect auxiliary sys/oracle@aux1connected to auxiliary database: aux1 (not mounted)RMAN> duplicate target database to aux1 pfile=/oracle/product/920/dbs/initaux1.ora ;Starting Duplicate Db at 04-MAY-04using target database controlfile instead of recovery catalogallocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: sid=11 devtype=DISKprinting stored script: Memory Script{set until scn 17929284;set newname for datafile 1 to"/oracle/oradata/aux1/system01.dbf";set newname for datafile 2 to"/oracle/oradata/aux1/undotbs01.dbf";set newname for datafile 3 to"/oracle/oradata/aux1/cwmlite01.dbf";set newname for datafile 4 to"/oracle/oradata/aux1/drsys01.dbf";set newname for datafile 5 to

Page 12: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

"/oracle/oradata/aux1/example01.dbf";set newname for datafile 6 to"/oracle/oradata/aux1/indx01.dbf";set newname for datafile 7 to"/oracle/oradata/aux1/odm01.dbf";set newname for datafile 8 to"/oracle/oradata/aux1/tools01.dbf";set newname for datafile 9 to"/oracle/oradata/aux1/users01.dbf";set newname for datafile 10 to"/oracle/oradata/aux1/xdb01.dbf";set newname for datafile 11 to"/oracle/oradata/aux1/T_HEALTH.dbf";restorecheck readonlyclone database;}executing script: Memory Scriptexecuting command: SET until clauseexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting restore at 04-MAY-04using channel ORA_AUX_DISK_1channel ORA_AUX_DISK_1: starting datafile backupset restorechannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setrestoring datafile 00001 to /oracle/oradata/aux1/system01.dbfrestoring datafile 00002 to /oracle/oradata/aux1/undotbs01.dbfrestoring datafile 00003 to /oracle/oradata/aux1/cwmlite01.dbfrestoring datafile 00004 to /oracle/oradata/aux1/drsys01.dbfrestoring datafile 00005 to /oracle/oradata/aux1/example01.dbfrestoring datafile 00006 to /oracle/oradata/aux1/indx01.dbfrestoring datafile 00007 to /oracle/oradata/aux1/odm01.dbfrestoring datafile 00008 to /oracle/oradata/aux1/tools01.dbfrestoring datafile 00009 to /oracle/oradata/aux1/users01.dbfrestoring datafile 00010 to /oracle/oradata/aux1/xdb01.dbfrestoring datafile 00011 to /oracle/oradata/aux1/T_HEALTH.dbfchannel ORA_AUX_DISK_1: restored backup piece 1piece handle=/rman_backups/bkup_HMDEV_14_1 tag=TAG20040505T043000params=NULL

Page 13: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

channel ORA_AUX_DISK_1: restore completeFinished restore at 04-MAY-04sql statement: CREATE CONTROLFILE REUSE SET DATABASE "aux1" RESETLOGSARCHIVELOGMAXLOGFILES 50MAXLOGMEMBERS 5MAXDATAFILES 100MAXINSTANCES 1MAXLOGHISTORY 226LOGFILEGROUP 1 ( '/oracle/oradata/aux1/redo01.log' ) SIZE 104857600 REUSE,GROUP 2 ( '/oracle/oradata/aux1/redo02.log' ) SIZE 104857600 REUSE,GROUP 3 ( '/oracle/oradata/aux1/redo03.log' ) SIZE 104857600 REUSEDATAFILE '/oracle/oradata/aux1/system01.dbf'CHARACTER SET AL32UTF8printing stored script: Memory Script{switch clone datafile all;}executing script: Memory Scriptdatafile 2 switched to datafile copyinput datafilecopy recid=1 stamp=525293003 filename=/oracle/oradata/aux1/undotbs01.dbfdatafile 3 switched to datafile copyinput datafilecopy recid=2 stamp=525293003 filename=/oracle/oradata/aux1/cwmlite01.dbfdatafile 4 switched to datafile copyinput datafilecopy recid=3 stamp=525293003 filename=/oracle/oradata/aux1/drsys01.dbfdatafile 5 switched to datafile copyinput datafilecopy recid=4 stamp=525293003 filename=/oracle/oradata/aux1/example01.dbfdatafile 6 switched to datafile copyinput datafilecopy recid=5 stamp=525293003 filename=/oracle/oradata/aux1/indx01.dbfdatafile 7 switched to datafile copyinput datafilecopy recid=6 stamp=525293003 filename=/oracle/oradata/aux1/odm01.dbfdatafile 8 switched to datafile copyinput datafilecopy recid=7 stamp=525293003 filename=/oracle/oradata/aux1/tools01.dbfdatafile 9 switched to datafile copyinput datafilecopy recid=8 stamp=525293003 filename=/oracle/oradata/aux1/users01.dbfdatafile 10 switched to datafile copyinput datafilecopy recid=9 stamp=525293003 filename=/oracle/oradata/aux1/xdb01.dbfdatafile 11 switched to datafile copy

Page 14: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

input datafilecopy recid=10 stamp=525293003 filename=/oracle/oradata/aux1/T_HEALTH.dbfprinting stored script: Memory Script{set until scn 17929284;recoverclone databasedelete archivelog;}executing script: Memory Scriptexecuting command: SET until clauseStarting recover at 04-MAY-04using channel ORA_AUX_DISK_1starting media recoveryarchive log thread 1 sequence 55 is already on disk as file /oracle/product/920/dbs/arch1_55.dbfarchive log filename=/oracle/product/920/dbs/arch1_55.dbf thread=1 sequence=55media recovery completeFinished recover at 04-MAY-04printing stored script: Memory Script{shutdown clone;startup clone nomount pfile= '/oracle/product/920/dbs/initaux1.ora';}executing script: Memory Scriptdatabase dismountedOracle instance shut downconnected to auxiliary database (not started)Oracle instance startedTotal System Global Area 139954912 bytesFixed Size 731872 bytesVariable Size 121634816 bytesDatabase Buffers 16777216 bytesRedo Buffers 811008 bytessql statement: CREATE CONTROLFILE REUSE SET DATABASE "aux1" RESETLOGSARCHIVELOGMAXLOGFILES 50MAXLOGMEMBERS 5MAXDATAFILES 100MAXINSTANCES 1MAXLOGHISTORY 226LOGFILEGROUP 1 ( '/oracle/oradata/aux1/redo01.log' ) SIZE 104857600 REUSE,GROUP 2 ( '/oracle/oradata/aux1/redo02.log' ) SIZE 104857600 REUSE,GROUP 3 ( '/oracle/oradata/aux1/redo03.log' ) SIZE 104857600 REUSEDATAFILE '/oracle/oradata/aux1/system01.dbf'CHARACTER SET AL32UTF8printing stored script: Memory Script

Page 15: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

{catalog clone datafilecopy "/oracle/oradata/aux1/undotbs01.dbf";catalog clone datafilecopy "/oracle/oradata/aux1/cwmlite01.dbf";catalog clone datafilecopy "/oracle/oradata/aux1/drsys01.dbf";catalog clone datafilecopy "/oracle/oradata/aux1/example01.dbf";catalog clone datafilecopy "/oracle/oradata/aux1/indx01.dbf";catalog clone datafilecopy "/oracle/oradata/aux1/odm01.dbf";catalog clone datafilecopy "/oracle/oradata/aux1/tools01.dbf";catalog clone datafilecopy "/oracle/oradata/aux1/users01.dbf";catalog clone datafilecopy "/oracle/oradata/aux1/xdb01.dbf";catalog clone datafilecopy "/oracle/oradata/aux1/T_HEALTH.dbf";switch clone datafile all;}executing script: Memory Scriptcataloged datafile copydatafile copy filename=/oracle/oradata/aux1/undotbs01.dbf recid=1 stamp=525296319cataloged datafile copydatafile copy filename=/oracle/oradata/aux1/cwmlite01.dbf recid=2 stamp=525296319cataloged datafile copydatafile copy filename=/oracle/oradata/aux1/drsys01.dbf recid=3 stamp=525296319cataloged datafile copydatafile copy filename=/oracle/oradata/aux1/example01.dbf recid=4 stamp=525296319cataloged datafile copydatafile copy filename=/oracle/oradata/aux1/indx01.dbf recid=5 stamp=525296319cataloged datafile copydatafile copy filename=/oracle/oradata/aux1/odm01.dbf recid=6 stamp=525296319cataloged datafile copydatafile copy filename=/oracle/oradata/aux1/tools01.dbf recid=7 stamp=525296319cataloged datafile copydatafile copy filename=/oracle/oradata/aux1/users01.dbf recid=8 stamp=525296320cataloged datafile copydatafile copy filename=/oracle/oradata/aux1/xdb01.dbf recid=9 stamp=525296320cataloged datafile copydatafile copy filename=/oracle/oradata/aux1/T_HEALTH.dbf recid=10 stamp=525296320datafile 2 switched to datafile copyinput datafilecopy recid=1 stamp=525296319 filename=/oracle/oradata/aux1/undotbs01.dbfdatafile 3 switched to datafile copyinput datafilecopy recid=2 stamp=525296319 filename=/oracle/oradata/aux1/cwmlite01.dbfdatafile 4 switched to datafile copyinput datafilecopy recid=3 stamp=525296319 filename=/oracle/oradata/aux1/drsys01.dbfdatafile 5 switched to datafile copyinput datafilecopy recid=4 stamp=525296319 filename=/oracle/oradata/aux1/example01.dbfdatafile 6 switched to datafile copyinput datafilecopy recid=5 stamp=525296319 filename=/oracle/oradata/aux1/indx01.dbfdatafile 7 switched to datafile copyinput datafilecopy recid=6 stamp=525296319 filename=/oracle/oradata/aux1/odm01.dbfdatafile 8 switched to datafile copyinput datafilecopy recid=7 stamp=525296319 filename=/oracle/oradata/aux1/tools01.dbf

Page 16: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

datafile 9 switched to datafile copyinput datafilecopy recid=8 stamp=525296320 filename=/oracle/oradata/aux1/users01.dbfdatafile 10 switched to datafile copyinput datafilecopy recid=9 stamp=525296320 filename=/oracle/oradata/aux1/xdb01.dbfdatafile 11 switched to datafile copyinput datafilecopy recid=10 stamp=525296320 filename=/oracle/oradata/aux1/T_HEALTH.dbfprinting stored script: Memory Script{Alter clone database open resetlogs;}executing script: Memory Scriptdatabase opened

Finished Duplicate Db at 04-MAY-042nd MethodAlso, refer the below article from metalink !!!

Recovery ScenariosRecovery Scenarios using RMANRecovery Scenarios using RMAN1.Point in Time Recoveryrun {allocate channel d1 type disk;set until time"to_date('2007-03-31:20:00:00','yyyy-mm-dd:hh24:mi:ss')";restore database;recover database;alter database open resetlogs;}2.Recovery from missing or corrupted datafile(s):This scenario deals with a situation where a datafile has gone missing, or is corrupted beyondrepair. For concreteness, we look at a case where a datafile is missing. Below is a transcript ofan SQL Plus session that attempts to open a database with a missing datafile (typed commands in bold, lines in italics are my comments, all other lines are feedback from SQL Plus):--open SQL Plus from the command line without--logging on to databaseC:\>sqlplus /nologSQL*Plus: Release 9.2.0.4.0 - Production on Tue Jan 2514:52:41 2005Copyright (c) 1982, 2002, Oracle Corporation. Allrights reserved.--Connect to the idle Oracle process as a privilegeduser and start up instanceSQL> connect / as sysdbaConnected to an idle instance.SQL> startup

Page 17: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

ORACLE instance started.Total System Global Area 131555128 bytesFixed Size 454456 bytesVariable Size 88080384 bytesDatabase Buffers 41943040 bytesRedo Buffers 1077248 bytesDatabase mounted.ORA-01157: cannot identify/lock data file 4 - see DBWR trace fileORA-01110: data file 4:'D:\ORACLE_DATA\DATAFILES\ORCL\USERS01.DBF'

SQL>The error message tells us that file# 4 is missing.Note that although the startup command has failed, the database is in the mount state. Thus, thedatabase control file, which is also the RMAN repository can be accessed by the instance andby RMAN. We now recover the missing file using RMAN. The transcript of therecovery session is reproduced below (bold lines are typed commands, comments in italics, therest is feedback from RMAN):--logon to RMANC:\>rman target /Recovery Manager: Release 9.2.0.4.0 - ProductionCopyright (c) 1995, 2002, Oracle Corporation. Allrights reserved.connected to target database: ORCL (DBID=1507972899)--restore missing datafileRMAN> restore datafile 4;Starting restore at 26/JAN/05using target database controlfile instead of recoverycatalogallocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=14 devtype=DISKallocated channel: ORA_DISK_2 channel ORA_DISK_2: sid=15 devtype=DISKchannel ORA_DISK_1: starting datafile backupset restorechannel ORA_DISK_1: specifying datafile(s) to restorefrom backup set restoring datafile 00004 toD:\ORACLE_DATA\DATAFILES\ORCL\USERS01.DBFchannel ORA_DISK_1: restored backup piece 1piece handle=D:\BACKUPQGB0UEC_1_1.BAKtag=TAG20050124T152708 params=NULLchannel ORA_DISK_1: restore completeFinished restore at 26/JAN/05--recover restored datafile - RMAN applies all logsautomaticallyRMAN> recover datafile 4;Starting recover at 26/JAN/05 using channel ORA_DISK_1using channel ORA_DISK_2starting media recoveryarchive log thread 1 sequence 4 is already on disk as file E:\ORACLE_ARCHIVE\ORCL_4.ARCarchive log thread 1 sequence 5 is already on disk as file C:\ORACLE_ARCHIVE\ORCL_5.ARCarchive log thread 1 sequence 6 is already on disk as file E:\ORACLE_ARCHIVE\ORCL_6.ARCarchive log thread 1 sequence 7 is already on disk as file E:\ORACLE_ARCHIVE\ORCL_7.ARC

Page 18: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

archive log filename=E:\ORACLE_ARCHIVE\ORCL_4.ARC thread=1 sequence=4archive log filename=C:\ORACLE_ARCHIVE\ORCL_5.ARC thread=1 sequence=5media recovery completeFinished recover at 26/JAN/05--open database for general useRMAN> alter database open;database openedRMAN>In the above scenario, the database is already in the mount state before the RMAN session is initiated. If the database is not mounted, you should issue a "startup mount" command before attempting to restore the missing datafile. The database must be mounted before any datafile recovery can be done. If the database is already open when datafile corruption is detected, you can recover the datafile without shutting down the database. The only additional step is to take the relevant tablespace offline before starting recovery. In this case you would perform recovery at the tablespace level. The commands are:C:\>rman target /Recovery Manager: Release 9.2.0.4.0 - ProductionCopyright (c) 1995, 2002, Oracle Corporation. Allrights reserved.connected to target database: ORCL (DBID=1507972899)--offline affected tablespaceRMAN> sql 'alter tablespace USERS offline immediate';using target database controlfile instead of recoverycatalogsql statement: alter tablespace USERS offline immediate--recover offlined tablespaceRMAN> recover tablespace USERS;Starting recover at 26/JAN/05allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=14 devtype=DISKallocated channel: ORA_DISK_2channel ORA_DISK_2: sid=12 devtype=DISKstarting media recoverymedia recovery completeFinished recover at 26/JAN/05--online recovered tablespaceRMAN> sql 'alter tablespace USERS online';sql statement: alter tablespace USERS online3.Recovery from block corruption:It is possible to recover corrupted blocks using RMAN backups. This is a somewhat exoticscenario, but it can be useful in certain circumstances, as illustrated by the following example.Here's the situation: a user connected to SQLPlus gets a data block corruptionerror when she queries a table. Here's a part of the session transcript:SQL> connect testuser/testpasswordConnected.SQL> select count(*) from test_table;select count(*) from test_table*ERROR at line 1:

Page 19: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

ORA-01578: ORACLE data block corrupted (file # 4,block # 2015)ORA-01110: data file 4:'D:\ORACLE_DATA\DATAFILES\ORCL\USERS01.DBF'Since we know the file and block number, we canperform block level recovery using RMAN. This is bestillustrated by example:C:\>rman target /Recovery Manager: Release 9.2.0.4.0 - ProductionCopyright (c) 1995, 2002, Oracle Corporation. Allrights reserved.connected to target database: ORCL (DBID=1507972899)--restore AND recover specific blockRMAN> blockrecover datafile 4 block 2015;Starting blockrecover at 26/JAN/05using target database controlfile instead of recoverycatalogallocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=19 devtype=DISKallocated channel: ORA_DISK_2 channel ORA_DISK_2: sid=20 devtype=DISKchannel ORA_DISK_1: restoring block(s)channel ORA_DISK_1: specifying block(s) to restore from backup set restoring blocks of datafile 00004channel ORA_DISK_1: restored block(s) from backup piece 1piece handle=E:\BACKUPQGB0UEC_1_1.BAK tag=TAG20050124T152708 params=NULLchannel ORA_DISK_1: block restore completestarting media recoverymedia recovery completeFinished blockrecover at 26/JAN/05RMAN>Now our user should be able to query the table from her SQLPlus session. Here's her session transcriptafter block recovery.SQL> select count(*) from test_table;COUNT(*)----------217001SQL>A couple of important points regarding block recovery:1. Block recovery can only be done using RMAN.2. The entire database can be open while performing block recovery.3. Check all database files for corruption. This is important - there could be other corrupted blocks. Verification of database files can be done using RMAN or the dbverify utility. To verify using RMAN simply do a complete database backup with default settings.If RMAN detects block corruption, it will exit with an error message pointing out the guilty file/block Recovery from missing or corrupted redo log group

Case 1: A multiplexed copy of the missing log is available.If a redo log is missing, it should be restored from a multiplexed copy, if possible. This is theonly way to recover without any losses. Here's an example, where I attempt to startup fromSQLPlus when a redo log is missing:

Page 20: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

SQL> startupORACLE instance started.Total System Global Area 131555128 bytesFixed Size 454456 bytesVariable Size 88080384 bytesDatabase Buffers 41943040 bytesRedo Buffers 1077248 bytesDatabase mounted.ORA-00313: open failed for members of log group 3 ofthread 1ORA-00312: online log 3 thread 1:'D:\ORACLE_DATA\LOGS\ORCL\REDO03A.LOG'SQL>To fix this we simply copy REDO03A.LOG from itsmultiplexed location on E: to the above location onE:. After copying the file, we issue an "alterdatabase open" from the above SQLPlus session:SQL> alter database open;Database altered.SQL>That's it - the database is open for use.Case 2: All members of a log group lost.In this case an incomplete recovery is the best we can do. We will lose all transactions from the missing log and all subsequent logs. We illustrate using the same example as above. The error message indicates that members of log group 3 are missing. We don't have a copy of this file, so we know that an incomplete recovery is required. The first step is to determinehow much can be recovered. In order to do this, we query the V$LOG view (when in the mount state) to find the system change number (SCN) that we can recover to (Reminder: the SCN is a monotonically increasing number that is incremented whenever a commit is issued):--The database should be in the mount state for v$log accessSQL> select first_change# from v$log where group#=3 ;FIRST_CHANGE#-------------370255SQL>The FIRST_CHANGE# is the first SCN stamped in the missing log. This implies that the last SCN stamped in the previous log is 370254 (FIRST_CHANGE#-1). This is the highest SCN that we can recover to. In order to do the recovery we must first restore ALL datafiles to this SCN, followed by recovery (also up to this SCN). This is an incomplete recovery, so we must open the database resetlogs after we're done. Here's a transcript of the recovery session (typed commands in bold, comments in italics, all other lines are RMAN feedback):C:\>rman target /Recovery Manager: Release 9.2.0.4.0 - ProductionCopyright (c) 1995, 2002, Oracle Corporation. Allrights reserved.connected to target database: ORCL (DBID=1507972899)--Restore ENTIRE database to determined SCNRMAN> restore database until scn 370254;

Page 21: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

Starting restore at 26/JAN/05using channel ORA_DISK_1using channel ORA_DISK_2channel ORA_DISK_1: starting datafile backupsetrestorechannel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 toD:\ORACLE_DATA\DATAFILES\ORCL\SYSTEM01.DBF restoring datafile 00004 toD:\ORACLE_DATA\DATAFILES\ORCL\USERS01.DBF channel ORA_DISK_2: starting datafile backupset restorechannel ORA_DISK_2: specifying datafile(s) to restore from backup set restoring datafile 00002 toD:\ORACLE_DATA\DATAFILES\ORCL\UNDOTBS01.DBF restoring datafile 00003 toD:\ORACLE_DATA\DATAFILES\ORCL\TOOLS01.DBF channel ORA_DISK_2: restored backup piece 1 piece handle=E:\BACKUPGB14IB_1_1.BAKtag=TAG20050124T171139 params=NULchannel ORA_DISK_2: restore completechannel ORA_DISK_1: restored backup piece 1piece handle=E:\BACKUPGB14IB_1_1.BAKtag=TAG20050124T171139 params=NULchannel ORA_DISK_1: restore completeFinished restore at 26/JAN/05--Recover databaseRMAN> recover database until scn 370254;Starting recover at 26/JAN/05using channel ORA_DISK_1using channel ORA_DISK_2starting media recoveryarchive log thread 1 sequence 9 is already on disk as file E:\ORACLE_ARCHIVE\ORCL_9.ARCarchive log thread 1 sequence 10 is already on disk as file E:\ORACLE_ARCHIVE\ORCL_10.ARCarchive log thread 1 sequence 11 is already on disk as file E:\ORACLE_ARCHIVE\ORCL_11.ARCarchive log thread 1 sequence 12 is already on disk as file E:\ORACLE_ARCHIVE\ORCL_12.ARCarchive log filename=E:\ORACLE_ARCHIVE\ORCL_9.ARC thread=1 sequence=9archive log filename=E:\ORACLE_ARCHIVE\ORCL_10.ARC thread=1 sequence=10media recovery completeFinished recover at 26/JAN/05--open database with RESETLOGS (see comments below)RMAN> alter database open resetlogs;database openedRMAN>The following points should be noted:1. The entire database must be restored to the SCN that has been determined by querying v$log.2. All changes beyond that SCN are lost. This method of recovery should be used only if you are sure that you cannot do better. Be sure to multiplex your redo logs, and (space permitting) your archived logs!3. The database must be opened with RESETLOGS, as a required log has not been applied.This resets the log sequence to zero, thereby rendering all prior backups worthless. Therefore, the first step after opening a database RESETLOGS is to take a fresh backup. Note that the RESETLOGS option must be used for any incomplete recovery.

Page 22: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

Recovery from missing or corrupted control file:Case 1: A multiplexed copy of the control file is available.On startup Oracle must read the control file in order to find out where the datafiles and online logs are located. Oracle expects to find control files at locations specified in the CONTROL_FILE initialisation parameter. The instance will fail to mount the database if any one of the control files are missing or corrupt. A brief error message will be displayed, with further details recorded in the alert log. The exact error message will vary depending on what has gone wrong. Here's an example:SQL> startupORACLE instance started.Total System Global Area 135338868 bytesFixed Size 453492 bytesVariable Size 109051904 bytesDatabase Buffers 25165824 bytesRedo Buffers 667648 bytesORA-00205: error in identifying controlfile, check alert log for more infoSQL>On checking the alert log, as suggested, we find the following:ORA-00202: controlfile: 'e:\oracle_dup_dest\controlfile\ORCL\control02.ctl'ORA-27046: file size is not a multiple of logical block sizeOSD-04012: file size mismatch (OS 5447783) The above corruption was introduced by manually editing the control file when the database was closed.The solution is simple, provided you have at least one uncorrupted control file - replace the corrupted control file with a copy using operating system commands. Remember to rename the copied file. The database should now start up without any problems Recover database by means of a backup from the old incarnation1. Obtain the primary key of the prior incarnation with a LIST command:# obtain primary key of old incarnationLIST INCARNATION OF DATABASE trgt;List of Database IncarnationsDB Key Inc Key DB Name DB ID STATUS ResetSCN Reset Time------- ------- ------- ------ ----------------- ----1 2 TRGT 1224038686 PARENT 1 02-OCT-021 582 TRGT 1224038686 CURRENT 59727 10-OCT-022. Make sure the database is started but not mounted:SHUTDOWN FORCE NOMOUNT3. Reset the incarnation to the primary key that you just obtained:# reset database to old incarnationRESET DATABASE TO INCARNATION 2;4. Recover the database, performing the following actions in the RUN command:• Set the end time for recovery to the time justbefore the loss of the data.• If automatic channels are not configured, thenmanually allocate one or more channels.• Restore the control file and mount it.• Restore and recover the database.For example, run the following commands:

Page 23: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

RUN{# set time to just before data was lost.SET UNTIL TIME 'Oct 8 2002 07:55:00';RESTORE CONTROLFILE; # FROM AUTOBACKUP not needed incatalog modeALTER DATABASE MOUNT; # mount database after restoringcontrol fileRESTORE DATABASE;RECOVER DATABASE;}5. If recovery is successful, then reset the online redo logs:# this command automatically resets the database so that this incarnation is the new incarnationALTER DATABASE OPEN RESETLOGS;RecoveryRestore from Cold BackupA cold backup is a backup performed while the database is off-line and unavailable to its users.Procedure for restore from cold backup1. Make sure source and destination databases are on the save version and patch (Very Important)2. create control file script from trace fileSQLPLUS> ALTER DATABASE backup controlfile to trace;SQLPLUS>SHOW PARAMETER UDUMP3. Shutdown the Source Database4. Copy all datafiles and trace file to the destination database (do not copy redo log files and control_files)5. startup nomount pfile=init.ora6. Create the script from the trace file. Here is the sampleCREATE CONTROLFILE SET DATABASE "DEV" RESETLOGSNOARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 2726LOGFILEGROUP 1 ( '/u02/oracle/oradata/DEV/redot1g1m2.log', '/u01/oracle/oradata/DEV/redot1g1m1.log' ) SIZE 10M,GROUP 2 ( '/u02/oracle/oradata/DEV/redot1g2m2.log', '/u01/oracle/oradata/DEV/redot1g2m1.log' ) SIZE 10M,GROUP 3 ( '/u01/oracle/oradata/DEV/redot1g3m1.log', '/u02/oracle/oradata/DEV/redot1g3m2.log' ) SIZE 10M,GROUP 4 ( '/u01/oracle/oradata/DEV/redot1g4m1.log', '/u02/oracle/oradata/DEV/redot1g4m2.log' ) SIZE 10MDATAFILE'/u02/oracle/oradata/DEV/system01.dbf','/u02/oracle/oradata/DEV/undotbs01.dbf','/u02/oracle/oradata/DEV/sysaux01.dbf','/u02/oracle/oradata/DEV/users01.dbf',

Page 24: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

'/u02/oracle/oradata/DEV/example01.dbf','/u02/oracle/oradata/DEV/data01.dbf','/u02/oracle/oradata/DEV/data02.dbf','/u02/oracle/oradata/DEV/data03.dbf','/u02/oracle/oradata/DEV/data04.dbf','/u02/oracle/oradata/DEV/index01.dbf','/u02/oracle/oradata/DEV/index02.dbf','/u02/oracle/oradata/DEV/index03.dbf','/u02/oracle/oradata/DEV/index04.dbf','/u02/oracle/oradata/DEV/lob01.dbf','/u02/oracle/oradata/DEV/bea01.dbf','/u02/oracle/oradata/DEV/beaidx01.dbf','/u02/oracle/oradata/DEV/bealob01.dbf'CHARACTER SET WE8ISO8859P1 ;7. Open the database with resetlogsSQL> @control_file.sql;Control file created.8. Open the database with resetlogsALTER DATASASE OPEN RESETLOGS;9. Create Temporary tablespaceALTER TABLESPACE TEMP ADD TEMPFILE ‘/opt/oracle/schedwin/temp01.dbf ’ size 150M;Restore from Hot BackupA hot backup is a backup performed while the database is on-line and available for read/write.Except for oracle exports, one can only do on-line backups when running in ARCHIVELOGmode.CASE 1: Restore database using RMAN Full backup.#1 Copy the following files to the target server-The database backup pieceControlfile backup pieceParameter file. i.e pfile.#2 Edit the parameter with new environment specificvalues#3 Start the database in nomount mode, using RMAN.$ Rman target /Recovery Manager: Release 9.2.0.6.0 - 64bit ProductionCopyright (c) 1995, 2002, Oracle Corporation. Allrights reserved.connected to target database (not started)RMAN> startup nomountOracle instance startedTotal System Global Area 773295264 bytesFixed Size 732320 bytesVariable Size 134217728 bytesDatabase Buffers 637534208 bytesRedo Buffers 811008 bytes#4 Restore control file from backup piece.RMAN> restore controlfile from'schedcd_633997804_109_1';

Page 25: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

#5 Mount the databaseRMAN>alter database mount;#6 Catalog the backup pieceRMAN>catalog backuppiece ‘schedcd_633997804_109_1';#7 Get to know the last sequence available in the archivelog backup using the followingcommand.RMAN> list backup of archivelog all;#8 Rename the redologsfiles, so that they can be created in a new location when opened inresetlogs.SQL>alter database rename file‘/opt/oracle/oradata/schedcd/redo/redoa1.log’ to‘/opt/oracle/oradata/schedwin/redo/redoa1.log’;…#9 Restore the datafiles to new locations and recoverRMAN> run{ set until sequenceset newname for datafile 1 to/opt/u01/oradata/schedwin/dbf/system01.dbf;set newname for datafile 2 to/opt/u01/oradata/schedwin/dbf/perfstat01.dbf;set newname for datafile 3 to/opt/u01/oradata/schedwin/dbf/cwmlite01.dbf;set newname for datafile 4 to/opt/u01/oradata/schedwin/dbf/drsys01.dbf;set newname for datafile 5 to/opt/u01/oradata/schedwin/dbf/indx01.dbf;set newname for datafile 6 to/opt/u01/oradata/schedwin/dbf/odm01.dbf;set newname for datafile 7 to/opt/u01/oradata/schedwin/dbf/tools01.dbf;set newname for datafile 8 to/opt/u01/oradata/schedwin/dbf/users01.dbf;set newname for datafile 9 to/opt/u01/oradata/schedwin/dbf/xdb01.dbf;set newname for datafile 10 to/opt/u02/oradata/schedwin/dbf/users02.dbf;set newname for datafile 11 to/opt/u03/oradata/schedwin/dbf/users03.dbf;set newname for datafile 12 to/opt/u01/oradata/schedwin/dbf/schedwin_indx01.dbf;set newname for datafile 14 to/opt/u02/oradata/schedwin/dbf/schedwin_indx02.dbf;set newname for datafile 16 to/opt/u01/oradata/schedwin/dbf/undotblspce01.dbf;restore database validate; # This is optionalrestore database;switch datafile all;recover database;

Page 26: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

alter database open resetlogs;}

Duplicate Database - RMANSource Server - linux1 - AIA (SID)Target Server - rac1 - CLON (Duplicate database SID)1> Take the AIA (source) backup using RMANrmanconnect targetrun {allocate channel d1 type disk maxpiecesize 2047M;backup format '/u01/oracle/rman_backup/AIA/df_t%t_s%s_p%p' database;sql 'alter system archive log current';backup format '/u01/oracle/rman_backup/AIA/al_t%t_s%s_p%p' archivelog all;backup format '/u01/oracle/rman_backup/AIA/control%U' current controlfile;delete noprompt archivelog all backed up 2 times to device type disk;release channel d1;}2> Create an Initialization Parameter for the Auxiliary Database-- connect to source serversqlplus "/ as sysdba"create pfile='/d02/oracle/AIA/ORACLE10g/dbs/initCLON.ora' from spfile;3> Create / Start the Auxiliary InstanceCopy oracle home from source server to target servercd /u01/rmantest/ORACLE10gscp -pr oracle@linux1:/d02/oracle/AIA/ .mkdir -p /u01/oracle/rman_backup/AIAcd /u01/oracle/rman_backup/AIAscp -pr oracle@linux1:/u01/oracle/rman_backup/AIA/* .4> Create Password File for Auxiliary Databasecd $ORACLE_HOME/dbsorapwd file=orapwCLON password=oracle entries=55> Create all needed directories for the duplicate database:export ORACLE_SID=CLONsqlplus "/ as sysdba"startup nomount6> Ensure Oracle Net Connectivity to Auxiliary Database-- listener.oraCLON =(ADDRESS_LIST =(ADDRESS= (PROTOCOL= IPC)(KEY= EXTPROCmanprod))(ADDRESS= (PROTOCOL= TCP)(Host= rac1.com )(Port= 1521)))SID_LIST_BEST =(SID_LIST =(SID_DESC =(ORACLE_HOME= /u01/rmantest/ORACLE10g)

Page 27: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

(SID_NAME = CLON))(SID_DESC =(SID_NAME = PLSExtProc)(ORACLE_HOME = /u01/rmantest/ORACLE10g)(PROGRAM = extproc)))-- tnsnames.oraCLON =(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = CLON)))AIA =(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = linux1)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = AIA)))8> Mount or Open the Target Databaseexport ORACLE_SID=AIA$ sqlplus "/ as sysdba"SQL> select status from v$instance;9> Ensure You Have the Necessary Backups and Archived Redo Log Files-- To know the time from the rman backuprem Filename: rmanstat.sqlrem Purpose: List completed RMAN backups for the last 24-hoursrem (use info from Dictionary - Control File Views)rem Date: 12-Feb-2000rem Author: Frank Naude, Oracle FAQrem -----------------------------------------------------------------------tti "RMAN Backups for last 24-hours"col type format a4col handle format a35 trunccol file# format 9999col duration format a9select decode(BACKUP_TYPE, 'L', 'ARCH', 'D', 'DB', 'I', 'INC','Unknown type='||BACKUP_TYPE) TYPE,to_char(a.start_time, 'DDMON HH24:MI') start_time,to_char(a.elapsed_seconds/60, '99.9')||' Min' DURATION,substr(handle, -35) handle,nvl(d.file#, l.sequence#) file#, nvl(d.blocks, l.blocks) blocksfrom SYS.V_$BACKUP_SET a, SYS.V_$BACKUP_PIECE b,

Page 28: ORACLE 11G Rman Complete handbook

PREPARED BY CHOWDARY

SYS.V_$BACKUP_DATAFILE d, SYS.V_$BACKUP_REDOLOG lwhere a.start_time between sysdate-1 and sysdateand a.SET_STAMP = b.SET_STAMPand a.SET_STAMP = d.SET_STAMP(+)and a.SET_STAMP = l.SET_STAMP(+)order by start_time, file#/10> Duplicate CLON from AIA instanceset -aLOG_FILE=CLON.logset +a(rman < < EOFCONNECT TARGET sys/oracle@AIACONNECT AUXILIARY sys/oracleRUN{set until time "to_date('OCT 31 2009 02:30:00','Mon DD Y Y Y Y HH24:MI:SS')";SET NEWNAME FOR DATAFILE 1 TO '/u01/rmantest/CLON/data/system01.dbf';SET NEWNAME FOR DATAFILE 2 TO '/u01/rmantest/CLON/data/undotbs01.dbf';SET NEWNAME FOR DATAFILE 3 TO '/u01/rmantest/CLON/data/sysaux01.dbf';SET NEWNAME FOR DATAFILE 4 TO '/u01/rmantest/CLON/data/users01.dbf';SET NEWNAME FOR DATAFILE 5 TO '/u01/rmantest/CLON/data/example01.dbf';set newname for tempfile 1 to '/u01/rmantest/CLON/data/temp.dbf';DUPLICATE TARGET DATABASE TO CLONLOGFILEGROUP 1 ('/u01/rmantest/CLON/data/redo1a.log') SIZE 50M reuse,GROUP 2 ('/u01/rmantest/CLON/data/redo1b.log') SIZE 50M reuse,GROUP 3 ('/u01/rmantest/CLON/data/redo2a.log') SIZE 50M reuse,GROUP 4 ('/u01/rmantest/CLON/data/redo2b.log') SIZE 50M reuse;}EOF) > $LOG_FILE 2>&1