Thursday, March 30, 2017

RMAN recovery on new machine

2:16 PM Posted by Dilli Raj Maharjan , 3 comments

Scenario:
Database Server is not available due to critical hardware failure. It may be some power issue resulting Mainboard, CPU, Memory, Storage failed. Fortunately we have backup on our DVD with the name bck.tar.gz. Backup contains the controlfile and spfile autobackup, archive logs and all RMAN backup pieces for all datafiles.

Please reinstall Oracle Software on the host we are trying to recover. Follow the URL below for the Oracle Software only installation. 


Do not install any database yet. In my case I have one existing rcat database on the machine on which I am planning to restore.

Extract the backup file. Since backup is in archive format, first I need to extract it. I am using /tmp as the destination to extract the file.



I switch to the rcat instance and export ORACLE_SID=orcl. Since I do not have any orcl instance I cannot directly switch to the orcl instance.



Startup database without any parameter file. In my case I need to restore my spfile too. Startup nomount force command will start oracle instance with the dummy parameter file.
startup nomount force.



Restore spfile with the autobackup.  This will restore the spfile. Database should be shutdown immediate and startup. Shutdown completed successfully but failed to start the instance . I am getting error as Unable to create audit trail file. We need to search for the parameter where my audit_file_dest is pointing.
restore spfile from '/tmp/bck/s_939891274.265.939891275';
shutdown immediate
startup nomount



Open spfile and find the directory where audit_file_dest is pointing. In this case it is pointing to /u01/app/oracle/admin/orcl/adump. Create directory with mkdir -p command.



Shutdown the database and startup with nomount option. Move ahead to restore controlfile.



Before restoring the controlfile we need to set dbid for the database to be restored. 
set dbid=1464472300

Restore controlfile from the same autobackup with the command below.
restore controlfile from '/tmp/bck/s_939891274.265.939891275';



Now we have successfully restored the controlfile. We can alter database to the mount state.
alter database mount;



Use list backup command to list the backup information stored on the controlfile.
list backup;

...


Verify all the File Names and make sure the directory exists before restore beings. In my case, some of the datafiles are stored on the OS directory. Make sure the directory exists if not, create them.



Copy backupset files from /tmp/bck directory to ASM directory. Make sure that you follow the following format. Each piece of backup file is on the following format:

Backup Piece name: nnndf0_TAG20170329T085330_0.276.939891255

Naming Defination: 

nnndf0: Backupset of datafiles without spfile
s indicates that the backup set includes the spfile; 
n indicates that the backup set does not include the spfile.

TAG20170329T085330_0: backup was initiated on 2017-03-20 08:53:30

276: File ID

939891255: Incarnation 


Never copy the incarnation value inside the ASM disk, this does not work and will give the error as below.


Instead use the syntax as below:
cp /tmp/bck/nnndf0_TAG20170329T085330_0.276.939891255 +fra/orcl/backupset/2017_03_29/nnndf0_TAG20170329T085330_0.276
cp /tmp/bck/nnndf0_TAG20170329T085330_0.279.939891271 +fra/orcl/backupset/2017_03_29/nnndf0_TAG20170329T085330_0.279
cp /tmp/bck/nnndf0_TAG20170329T085330_0.280.939891241 +fra/orcl/backupset/2017_03_29/nnndf0_TAG20170329T085330_0.280
cp /tmp/bck/nnndf0_TAG20170329T085330_0.282.939891225 +fra/orcl/backupset/2017_03_29/nnndf0_TAG20170329T085330_0.282
cp /tmp/bck/nnndf0_TAG20170329T085330_0.301.939891211 +fra/orcl/backupset/2017_03_29/nnndf0_TAG20170329T085330_0.301
cp /tmp/bck/s_939891274.265.939891275 +fra/orcl/backupset/2017_03_29/s_939891274.265.939891275
cp /tmp/bck/thread_1_seq_139.264.939891817 +fra/orcl/archivelog/2017_03_29/thread_1_seq_139.264
cp /tmp/bck/thread_1_seq_140.312.939891821 +fra/orcl/archivelog/2017_03_29/thread_1_seq_140.312



Execute crosscheck backup to verify the backup really exists on the required location. Make sure all the backup piece have the status Available.



Now we can start restoring the backup with the command below:
restore database;



Once restore is completed execute recover database to recover database till the archivelog exists.



Open database with the resetlogs option. Since block change tracking is enabled and the file is missing on our environment we can simply disable the block change tracking and move ahead with the alter database open.



Database restore and recover completed successfully. We can now access database with the database users.

3 comments:

  1. Hi,

    Open spfile and find the directory where audit_file_dest is pointing. In this case it is pointing to /u01/app/oracle/admin/orcl/adump. Create directory with mkdir -p command.

    Awesome solution.. It may have pfile instead of spfile.

    Thanks,
    PK pandey

    ReplyDelete
    Replies
    1. Hi,
      Thank you for the comment. You are true that you can open pfile instead of spfile. In my case I do not have pfile so I open the spfile with command cat. You can read spfile content too with cat command.

      Regards,
      Dilli Raj Maharjan

      Delete
  2. Thanks for good info dilli raj maharjan.

    ReplyDelete