In this example scenario:
RMAN making backups into the /oracle/rman/ directory, at the same time backups were being copied onto a different machine on the network.
The disk with the /oracle/rman/ directory has failed, making the backups unavailable. Backups were then copied to /oracle/rman1/.
At the same time:
The “oratr” disk /oracle/oradata/oratr/ which contains the redologs, controlfiles and datafiles has also failed. A new disk is installed and mounted on the yenioratr directory /oracle/oradata/yenioratr.
This is illustrated here:
Step 1: Delete dbf, redo logs and control files in order to implement the scenario.
1 2 3 |
SQL> shutdown immediate oracle@dataera.com~ $ cd /oracle/oradata/oratr oracle@dataera.com~ $ rm * |
1 2 3 4 5 6 7 8 |
SQL> startup ORACLE instance started. Total System Global Area 910163968 bytes Fixed Size 1283380 bytes Variable Size 230689484 bytes Database Buffers 675282944 bytes Redo Buffers 2908160 bytes ORA-00205: error in identifying control file, check alert log for more info |
Step 2: As part of the scenario, backups that were made to the /oracle/rman folder using rman need to be moved to another disk/folder (making a copy of the directory on the network).
1 |
oracle@dataera.com~ $ mv /oracle/rman/* /oracle/rman1/ |
By restoring the backups to a different location we can now recover the database.
Step 3: Restoring the controlfile to a new location.
1 2 3 4 5 |
RMAN> set dbid 3117323921; RMAN> set controlfile autobackup format for device type disk to '/oracle/rman1/%F'; RMAN> RESTORE CONTROLFILE TO '/oracle/oradata/neworatr/control01.ctl' from autobackup; RMAN> RESTORE CONTROLFILE TO '/oracle/oradata/neworatr/control02.ctl' from autobackup; RMAN> RESTORE CONTROLFILE TO '/oracle/oradata/neworatr/control03.ctl' from autobackup; |
Had the restore been to the first location, i.e. if /oracle/oradata/oratr/ was in a good condition the following command could have been used:
1 |
RMAN> restore controlfile from autobackup; (/oracle/oradata/oratr/) |
Note: The new control file paths need to be written to pfile.ora in order to re-open the database with the updated spfile. RMAN would then need to be reconnected in mount mode.
Check the updated control file paths using the following query:
1 |
RMAN> select * from v$controlfile; |
Step 4: The new backups need to be identified to RMAN because location where the backups are now stored in a different location.
1 |
RMAN> CATALOG START WITH '/oracle/rman1/'; |
Alternatively:
1 2 3 4 5 |
RMAN> CATALOG BACKUPPIECE '/oracle/rman1/c-3117323921-20110531-04'; RMAN> CATALOG BACKUPPIECE '/oracle/rman1/ora_df_752578940_69_1'; RMAN> CATALOG BACKUPPIECE '/oracle/rman1/ora_df_752578825_68_1'; RMAN> CATALOG BACKUPPIECE '/oracle/rman1/ora_df_752578823_67_1'; RMAN> CATALOG BACKUPPIECE '/oracle/rman1/ora_df_752578814_66_1'; |
1 2 |
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oracle/rman1/%F'; RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/oracle/rman1/ora_df_%t_%s_%p'; |
Step 5: Updating the control file with the redo log directories. (This step may need to be done after Step 6)
1 2 3 |
SQL> alter database rename file '/oracle/oradata/oratr/redo01.log' to '/oracle/oradata/neworatr/redo01.log' ; SQL> alter database rename file '/oracle/oradata/oratr/redo02.log' to '/oracle/oradata/neworatr/redo02.log' ; SQL> alter database rename file '/oracle/oradata/oratr/redo03.log' to '/oracle/oradata/neworatr/redo03.log' ; |
Step 6: Restore and recover the datafiles, start the server using open reset logs. (We use reset logs because there aren’t any redo logs)
1 2 3 4 5 6 |
RMAN> set head off RMAN> set pagesize 100 RMAN> select 'set newname for datafile '||file_id||' to '''||'/oracle/oradata/yenioratr/'||''';' from dba_data_files; RMAN> select 'set newname for tempfile '||file_id||' to '''||'/oracle/oradata/yenioratr/'||''';' from dba_temp_files; |
1 2 3 4 5 6 7 8 9 10 |
RMAN> run { set newname for datafile 1 to '/oracle/oradata/neworatr/system01.dbf'; set newname for datafile 2 to '/oracle/oradata/neworatr/undotbs01.dbf'; set newname for datafile 3 to '/oracle/oradata/neworatr/sysaux02.dbf'; set newname for datafile 4 to '/oracle/oradata/neworatr/users01.dbf'; set newname for datafile 5 to '/oracle/oradata/neworatr/example01.dbf'; restore database; switch datafile all; recover database; alter database open resetlogs; } |
1 2 3 4 5 6 7 8 9 |
SQL> select ts.name tablespace, df.file#, df.name datafile 2 from v$tablespace ts, v$datafile df 3 where ts.ts# = df.ts#; 4 /oracle/oradata/oratr/system01.dbf 1 5 /oracle/oradata/oratr/undotbs01.dbf 2 6 /oracle/oradata/oratr/sysaux02.dbf 3 7 /oracle/oradata/oratr/users01.dbf 4 8 /oracle/oradata/oratr/example01.dbf 5 9 /oracle/oradata/oratr/user_index.dbf 6 |
Note: Use the following code in situations where the pfile, spfile or any other necessary files can’t be found:
1 2 |
SQL> startup force nomount; SQL> restore spfile from autobackup; |
Using RMAN for...
12 March 2019