Friday, November 8, 2013

Restore and recover an Oracle database to a new host

I promised it long time after receiving to many requests I decided to share it with you today. Many people usually prefer to work with mysql instead of oracle (no debate !!!) because with mysql they can easily export and import their database. But Oracle that so inflexible ? No. As you will see you can easily export (backup) and recover (import)  an Oracle database between two hosts (I am using Wxp) using the RMAN power.

Note:
H1: current host.
H2: new host.

  1. Backup H1 using RMAN.
  2. in host H1:
         Make sure H1 is in archivelog mode and rman autobackup on...
      rman> backup database;
  3.  transfer the backup of H1 to host H2 (flash_recovery_area = C:\oracle\product\10.2.0\flash_recovery_area)
  4. Determine the DBID of host H1
    • Now on host H2, make sure it has been shutdown. 
    •  -set the oracle_sid same as for H1 
    •   -rman target /
     
  5.  -set the oracle_sid same as for H1 
  6.   -rman target /
  7.  rman> set dbid dbid_of_H1
  8.  rman> startup nomount
  9.  rman> restore controlfile from autobackup;
  10.  rman> alter database mount;
  11. list the backup and take the SCN (scn_nb) number...
          rman> list backup
  12. restore and recover

          rman> run
                {
                set until scn scn_nb
                restore database;
                switch datafile all;
                recover database;
                };

          if receive ORA-19698 telling the dbid is different...
          Solution: replace the redologs ( located inside oradata) file in H2 wiht the one in H1
          Then run run{...} again
  13. open the database resetlog option.
            rman> alter database open resetlogs;

Note: Sometimes you have to backup database plus archivelog in order to avoid ORA-19698.

I hope from now on you will have fun with it. You feedback is always welcome.

No comments:

Post a Comment