Restore RMAN full backup to different server with same database name but different directory structure::
In this article we are going to learn, how to restore RMAN full backup to a different server with same database name but different directory structure.
Overview:
This article is a comprehensive guide for restoring RMAN full backup to a different server with same database name but different directory structure.
Please do keep in mind that this article should not be considered a substitution of the official guide from Oracle (
http://www.oracle.com). The below mentioned link can be used to download the official documentation for RMAN Recovery Techniques.
Names used in this article:
Name | Value |
Database Name | mydb |
Backup Folder on Node1 | c:\rman_bck |
Backup Folder on Node2 | c:\rman_bck |
Database (Datafile/Controlfile/redolog) Folder on Node1 | ORACLE_BASE\oradata\mydb |
Database (Datafile/Controlfile/redolog) Folder on Node2 | ORACLE_BASE\oradata\mydbtest |
Connect to the database:
Open command prompt and type the below mentioned:
cmd> set ORACLE_SID=mydb
cmd> sqlplus / as sysdba
Create initialization parameter file (pfile).
sql>create pfile from spfile ;
Take Full Backup of Database using RMAN:
Open command prompt and type the below mentioned:
cmd> rman target /
We can configure the backup location (if not configured earlier). For configuring backup location type the following command:
RMAN> configure channel device type disk format 'C:\rman_bck\mydb_%U' ;
For taking backup of the database, fire the below mentioned command:
RMAN> backup database plus archivelog ;
Copy the required files to the other node:
Copy the below mentioned files to the other node:
--The backup pieces generated using RMAN.
--The initalization parameter file( created above).
--The password file( We can create it also on the other node).
Create database directory structure on other node:
Create "oradata/mydbtest" directory on the other node ( for storing controlfiles,datafiles,redo logfiles ). Also create Archive Destination Directory.
Create Service/instance on other node:
Note:This step needs to be performed only on Windows O/S.
Create a service( Here in my case my datbase name -- mydb ).For creating service use "oradim" utility. As mentioned below:
cmd> oradim -new -sid mydb -intpwd sys -startmode manual
After creating the service, change its startmode to automatic. For doing so go to "windows services" and change its startmode to automatic.
Edit PFILE on the other node:
Edit the PFILE and change the location of control_files/audit_file_dest as per the new directory structure on the other node.
Start the database in nomount mode on other node:
Open command prompt and type the below mentioned commands:
cmd> set ORACLE_SID=mydb
cmd> sqlplus / as sysdba
Start database with PFILE:
sql> startup nomount pfile='full_path_of_pfile' ;
Invoke RMAN on other node:
Open command prompt and type the below mentioned:
cmd> rman target /
Restore Controlfile:
Restore the controlfile from the backup pieces as mentioned below:
RMAN> restore controlfile from 'full_path_control_file_bck_piece' ;
Mount the Database:
After restoring the controlfile from the backuppieces mount the database :
RMAN> alter database mount ;
Rename the Redologfiles:
After mounting the database, Rename the Redologfiles,so that they can be created in new locations when the database is opened with resetlogs option, For renaming the redologs open a new command prompt and connect to the database from that prompt, as mentioned below:
On the second Node (Node2)
SQL> alter database rename file 'redo_file_loc_first_node\redo01.log' to 'redo_file_loc_second_node\redo01.log';
SQL> alter database rename file 'redo_file_loc_first_node\redo02.log' to 'redo_file_loc_second_node\redo02.log';
.....................
SQL> alter database rename file 'redo_file_loc_first_node\redoN.log' to 'redo_file_loc_second_node\redoN.log';
Get the Datafile Info of Node 1:
Connect to the database of Node 1 and query the "DBA_DATA_FILES" for datafiles info, as mentioned below:
SQL> select file_id , file_name from dba_data_files ;
Restore and Recover the Database:
After collecting datafile information of Node 1, Now restore the datafiles to new locations and recover ( On Node2 ), as mentioned below:
RMAN> run {
set newname for datafile 1 to 'datafile_loc_node2\system01.dbf' ;
set newname for datafile 2 to 'datafile_loc_node2\sysaux01.dbf' ;
set newname for datafile 3 to 'datafile_loc_node2\undotbs01.dbf' ;
set newname for datafile 4 to 'datafile_loc_node2\user01.dbf' ;
set newname for datafile 5 to 'datafile_loc_node2\tools.dbf' ;
................ //mention all the datafiles
restore database ;
switch datafile all ;
recover database ;
}
If it show error ("media recovery requesting unknown archived log") that means, it requires the new archivelogs, copy the new archivelogs from node1 to node2 and rerurn the above command "recover database". (We can ignore this error).
Open the Database with Resetlogs:
After that, open the database with resetlogs options. As mentioned below:
RMAN> alter database open resetlogs;
Connect to the database & create spfile:
After that, Connect to the database and create spfile. As mentioned below:
cmd> sqlplus / as sysdba
SQL> create spfile from pfile='pfile_location';
This finishes restoring RMAN full backup to a different server with same database name but different directory structure.