VirtualObjectives

Restore to a Test Oracle RAC Environment

The following procedure describes how to restore a Production database into a two node Test RAC environment.
It focuses on Oracle 10G in a RAC environment hosted by Windows servers.
If you don't use things like ASM, Diskgroups, Oracle Enterprise Manager (OEM) Database Control, etc. then just skip over them.

Backup the production database using RMAN. The backup should include control files and archive logs. Copy these to your Test server in a location I'll call from now on S:\RMAN_BACKUP\

Shut Down the RAC:

Shut down Oracle on RAC node 2:

Shut down Oracle Enterprise Manager (OEM) Database Control and shut down Oracle.

Shut down ASM on RAC node 2:

On RAC node 1, stop the Task Scheduler and shut down oracle.

On RAC node 1:
Turn off oracle RAC clustering for the duration of the restore process.
Edit the file %ORACLE_HOME%\admin\\pfile\init.ora

Comment out by adding # in front of the following...

Uncomment or add the lines...

On RAC node 1:

Shut down Oracle Enterprise Manager (OEM) Database Control and start up Oracle in NOMOUNT.

Display the cluster parameters to check that cluster_database_instances is 1.
Also note that cluster_database is FALSE.

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----
cluster_database                     boolean     FALSE
cluster_database_instances           integer     1

Display the LOG_ARCHIVE_DEST_1 parameter value which will be used below.

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1                   string      LOCATION=+DG2/sid/admin/arch
                                                 ive mandatory REOPEN=120

Empty the datafiles from the Diskgroup using ASMCMD:

Use the following examples to remove datafiles and archive logs. Directories used my not be the same.
This can take a long time to do and it can look like ASMCMD has frozen.
You could run another ASMCMD session and run lsdg to show the progress of the deletion.

ASMCMD> rm -r dg2/sid/ARCHIVELOG/*
ASMCMD> rm -r dg2/sid/archive/*
ASMCMD> rm dg1/sid/DATAFILE/*
ASMCMD> rm dg1/sid/TEMPFILE/*
ASMCMD> rm dg1/sid/*.dbf

Check that the files have been removed...

ASMCMD> ls dg2/sid/ARCHIVELOG
ASMCMD> ls dg1/sid/DATAFILE
ASMCMD> ls dg1/sid/TEMPFILE

You may now need to create the directory structure to host the soon to be restored files...

ASMCMD> mkdir dg2/sid/ARCHIVELOG
ASMCMD> mkdir dg1/sid/DATAFILE
ASMCMD> mkdir dg1/sid/TEMPFILE

Check free space from ASMCMD:

ASMCMD> lsdg

Check free space using SQLPlus:

Restoring the Database:

Start up ASM on RAC node 2:

On RAC node 1, create another directory called S:\RMAN_BACKUP_OTHER\ for example.
Move all non-backup files from S:\RMAN_BACKUP\ to S:\RMAN_BACKUP_OTHER\
These are files like control files and archive logs.
What is left in S:\RMAN_BACKUP\ should only be backup files from a compressed backup set.

On RAC node 1, connect to the database as the RMAN target.

Shut down the database and start it again in nomount:

RMAN> shutdown immediate
RMAN> startup nomount;

Restore the control file.

RMAN> RESTORE CONTROLFILE FROM 'S:\RMAN_BACKUP_OTHER\_CTL_XXXXXXXXXXXXXXXXXXXX';

Mount the database.

RMAN> alter database mount;

Catalog the backup files.

RMAN> CATALOG START WITH 'S:\RMAN_BACKUP\';

Create a text file in E:\Scripts\ called restore.rman (for example) and add the following...

run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
restore database;
}

Restore the database.

RMAN> @e:\scripts\restore.rman

Create a text file in E:\Scripts\ called restore_archivelogs.rman (for example) and add the following.
Replace the value for LOG_ARCHIVE_DEST_1 to what was obtained above.

run 
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;

# Same as parameter LOG_ARCHIVE_DEST_1
set archivelog destination to '+DG2/sid/admin/archive/';
restore archivelog all;
#restore archivelog logseq nnnnn thread n;

release channel c1;
release channel c2;
release channel c3;
}

Restore the archivelogs.

RMAN> @e:\scripts\restore_archivelogs.rman

Database Recovery:

Open a new command prompt.

NOTE: You will need to rerun the previous step (archive log restore) and this step (database recovery) to get all the archive logs applied.
This is done by changing the file restore_archivelogs.rman and commenting out "restore archivelog all;" with # and uncomment the line above "restore archivelog logseq nnnnn thread n;" by removing #.
Then change the sequence number and thread number to what is displayed.
Once the RMAN restore of the particular archive log file is done, press [Enter] in the recovery SQLPlus session to recover it.
The next sequence number and thread are displayed, then just update the file restore_archivelogs.rman with the new values and executing it again to restore the file and then press [Enter] to recover it.
Continue applying redo log files until the last log has been applied to the restored datafiles.
When the restore archivelog process stop with an error, then cancel recovery by executing the following command: CANCEL and proceed to the next step below.

Check the Oracle alert logs for issues.

Turn on oracle RAC clustering:

Edit the file %ORACLE_HOME%\admin\\pfile\init.ora

Uncomment by removing # from the following lines...

Comment out the following two lines with # ...

Check the Oracle alert logs for issues.

On RAC node 2:

Check the Oracle alert logs on both nodes for issues.

Check all RAC services are ONLINE as per below:

At this point you will need to apply post restore steps to conform with the Test environment which may differ to Production.