Restore and Recovery of the Database on a New Host

Preparing for Restore of a Database to a New Host

To prepare for the restore of the database to a new host, take the following steps:

Record the DBID for your source database.
If you do not have a record of the DBID of your database, there are two places you can find it without opening your database.

1. Check-Configuring the Control File Autobackup Format
By default, the format of the autobackup file for all configured devices is the substitution variable %F. This variable format translates into c-IIIIIIIIII-YYYYMMDD-QQ, where:

IIIIIIIIII stands for the DBID.

YYYYMMDD is a time stamp of the day the backup is generated

QQ is the hex sequence that starts with 00 and has a maximum of FF

2. RMAN Logs
If you have any text files that preserve the output from an RMAN session, the DBID is displayed by the RMAN client when it starts up and connects to your database. Typical output follows:

Make sure backups used for the restore are accessible on the restore host
% rman TARGET /
Recovery Manager: Release 11.2.0.3.0 – Production on Sun Jun 12 02:41:03 2005

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: RDBMS (DBID=774627068)

RMAN>

Testing the Restore of a Database to a New Host: Scenario
This scenario assumes the following:

1. Two networked machines, hosta and hostb, are running Linux
2. A target database named trgta is on hosta and uses a recovery catalog catdb
3. You want to test the restore and recovery of trgta on hostb, while keeping database trgta
up and running on hosta
4. The directory structure of hostb is different from hosta, so that
trgta is located in /net/hosta/dev3/oracle/dbs, but you want to
restore the database to /net/hostb/oracle/oradata/test

5. Database trgta uses a server parameter file
6. The ORACLE_SID for the trgta database is trgta and will not change for the restored database
7. You have a record of the DBID for trgta
8. A media manager is accessible by both machines
9. You have recoverable backups on tape of all datafiles
Note:- We may have other backup device containing the backup of database

10.You have backups of the archived logs required to recover the datafiles
11.You have control file and server parameter file autobackups on tape

Use the following steps to perform the restore process:-

While connected to hostb with administrator privileges, edit the /etc/group file so that you are included: in the DBA group:

dba:*:614:

Set the ORACLE_SID environment variable on hostb to the same value used on hosta:

% setenv ORACLE_SID trgta    (win)
OR
export ORACLE_SID=trgta      (linux/unix)

Start RMAN and connect to the target instance without connecting to the recovery catalog.

% rman TARGET / NOCATALOG

Run SET DBID to set the DBID, then run STARTUP NOMOUNT:

SET DBID 1340752057;
STARTUP NOMOUNT

RMAN will fail to find the server parameter file, which has not yet been restored, but will start the instance with a “dummy” file. Sample output follows:

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/net/hostb/oracle/dbs/inittrgta.ora'

trying to start the Oracle instance without parameter files ...
Oracle instance started

Restore and edit the server parameter file.

Because you enabled the control file autobackup feature when making your backups, the server parameter file is included in the backup sets.

Allocate a channel to the media manager, then restore the server parameter file (SPFILE) as a client-side parameter file (PFILE).

RUN
{
  ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS='...';
  RESTORE SPFILE TO PFILE '?/oradata/test/inittrgta.ora' FROM AUTOBACKUP;
  SHUTDOWN ABORT;
}

Next, edit the restored PFILE. Change any location-specific parameters, for example, those ending in _DEST and _PATH, to reflect the new directory structure. For example, edit the following parameters:

  - IFILE
  - *_DUMP_DEST
  - LOG_ARCHIVE_DEST*
  - CONTROL_FILES

Then restart the instance, using the edited PFILE:

STARTUP FORCE NOMOUNT PFILE='?/oradata/test/inittrgta.ora';

Restore the control file from an autobackup and then mount the database. RMAN restores the control file to whatever location you specified in the CONTROL_FILES initialization parameter. For example:

    RUN
    {
      ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS='...';
      RESTORE CONTROLFILE FROM AUTOBACKUP;
      ALTER DATABASE MOUNT;
    }

Query the database filenames recorded in the control file on the new host (hostb). Because the control file is from the trgta database, the recorded filenames use the original hosta filenames. You can query V$ views to obtain this information. Start a new SQL*Plus session and connect to the newly created instance on hostb:

    % sqlplus '/ AS SYSDBA'

    Run the following query in SQL*Plus:

    SQL> COLUMN NAME FORMAT a60
    SQL> SPOOL LOG 'db_filenames.out'
    SQL> SELECT FILE# AS "File/Grp#", NAME FROM V$DATAFILE
         UNION
         SELECT GROUP#,MEMBER FROM V$LOGFILE;
    SQL> SPOOL OFF
    SQL EXIT

Write the RMAN recovery script.
1. For each datafile on the destination host that is restored to a different path than it had on the source host, use a SET NEWNAME command to specify the new path on the destination host. (If the file systems on the destination system are set up to have the same paths as the source host, then do not use SET NEWNAME for those files restored to the same path as on the source host.)

2.For each online redo log that is to be created at a different location than it had on the source host, use SQL ALTER DATABASE RENAME FILE commands to specify the pathname on the destination host. (If the file systems on the destination system are set up to have the same paths as the source host, then do not use ALTER DATABASE RENAME FILE for those files restored to the same path as on the source host.)

3.Perform a SET UNTIL to limit media recovery to the end of the archived redo logs.

4.Run SWITCH so that the control file recognizes the new path names as the official new names of the datafiles

5.Restore and recover the database

For example, consider the following RMAN script to perform these steps, which is contained in text file reco_test.rman:

RUN
{
  # allocate a channel to the tape device
  ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS='...';

  # rename the datafiles and online redo logs
  SET NEWNAME FOR DATAFILE 1 TO '?/oradata/test/system01.dbf';
  SET NEWNAME FOR DATAFILE 2 TO '?/oradata/test/undotbs01.dbf';
  SET NEWNAME FOR DATAFILE 3 TO '?/oradata/test/cwmlite01.dbf';
  SET NEWNAME FOR DATAFILE 4 TO '?/oradata/test/drsys01.dbf';
  SET NEWNAME FOR DATAFILE 5 TO '?/oradata/test/example01.dbf';
  SET NEWNAME FOR DATAFILE 6 TO '?/oradata/test/indx01.dbf';
  SET NEWNAME FOR DATAFILE 7 TO '?/oradata/test/tools01.dbf';
  SET NEWNAME FOR DATAFILE 8 TO '?/oradata/test/users01.dbf';
  SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo01.log''
      TO ''?/oradata/test/redo01.log'' ";
  SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo02.log''
      TO ''?/oradata/test/redo02.log'' ";

  # Do a SET UNTIL to prevent recovery of the online logs
  SET UNTIL SCN 123456;
  # restore the database and switch the datafile names
  RESTORE DATABASE;
  SWITCH DATAFILE ALL;

  # recover the database
  RECOVER DATABASE;
}
EXIT

Online logs and datafiles are relocated as specified,

For example, connect and execute the script as shown here:

% rman TARGET / NOCATALOG
RMAN> @reco_test.rman

RMAN will apply as many of the archived redo logs as it can and leave the database in a state in which is can be opened.

Now perform an OPEN RESETLOGS at the restored database.

From the RMAN prompt, open the database with the RESETLOGS option:

RMAN> ALTER DATABASE OPEN RESETLOGS;

🙂

http://docs.oracle.com/cd/B19306_01/backup.102/b14191/rcmrecov.htm#i1007814

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s