1) Copy the RMAN backup taken from source to destination server.
2) On new server set the environment variables as given below
export ORACLE_SID= <SID of Source Database>
export ORACLE_HOME=<Path of Oracle Home on the new server>
3) Invoke the RMAN prompt without connecting it to the recovery catalog.
rman target /
4) Startup the instance in nomount state with default parameters as below
RMAN> startup nomount force;
5) Restore the spfile from the RMAN backup.
RMAN> catalog start with ‘PATH of backup piece which contain spfile’;
RMAN>restore spfile to <New Oracle Home Path/dbs>
from '<Name & absolute path of the backup piece which contain spfile>';
6) Once the spfile has been restored to desired path, create a pfile from newly restored spfile.
export ORACLE_SID= <SID of Source Database>
export ORACLE_HOME=<Path of Oracle Home on the new server>
Sqlplus / as sysdba
SQL> create pfile=’< New Oracle Home Path/dbs>’ from spfile=’ <Name & absolute path of the spfile>’;
7) Now shut down the instance started at nomount state in step no 4.
SQL> shut immediate;
8) Now modify the pfile parameters such that it will point to the new path on new server.
*.audit_file_dest=
*control_files=
*.db_recovery_file_dest_size=
*.db_recovery_file_dest=
*.diagnostic_dest=
*.log_archive_dest_1=
*.local_listener=
9) Now start the database with newly restored & modified pfile as shown below
export ORACLE_SID= <SID of Source Database>
export ORACLE_HOME=<Path of Oracle Home on the new server>
sqlplus / as sysdba
SQL> startup nomount pfile=’<Absolute path of the pfile>’;
10) Now restore the controlfile on new server as given below.
rman target /
RMAN> catalog start with ‘<Absolute path of the backup piece contain control file>’;
RMAN> restore controlfile from ‘<Absolute path of the backup piece contain control file >’;
11) Once the controlfile is successfully restored, start the database in mount state.
RMAN> sql ‘alter database mount’; OR RMAN> alter database mount;
12) Now register all the backup pieces with the newly restored controlfile.
RMAN> catalog start with ‘<Absolute path of the backup >’;
13) Open a new sqlplus session.
export ORACLE_SID= <SID of Source Database>
export ORACLE_HOME=<Path of Oracle Home on the new server>
sqlplus / as sysdba
14) Now rename the redolog files
alter database rename file '/prod/oradata/log01.dbf' to '/test/oradata/log01.dbf';
alter database rename file '/prod/oradata/log02.dbf' to '/test/oradata/log02.dbf';
15) As we are restoring the backup on new server where the path of the datafile may be different, we need to set new name for all the datafiles, so run the below command to achieve this.
set head off pages 0 feed off echo off verify off
set lines 200
spool rename_datafiles.lst
select ‘SET NEWNAME FOR DATAFILE ‘ || FILE# || ‘ TO ”’ || ‘<NEW PATH>’ ||
substr(name,instr(name,’/’,-1)+1) || ”';’ from v$datafile;
spool off
exit;
16) Now restore the database using below rman command.
run{
SET NEWNAME FOR DATAFILE 1 TO '+DATA/system01.dbf';
SET NEWNAME FOR DATAFILE 2 TO '+DATA/sysaux01.dbf';
SET NEWNAME FOR DATAFILE 3 TO '+DATA/undotbs01.dbf';
SET NEWNAME FOR DATAFILE 4 TO '+DATA/users01.dbf';
SET NEWNAME FOR DATAFILE 5 TO '+DATA/threatened_fauna_data.dbf';
SET NEWNAME FOR DATAFILE 6 TO '+DATA/example_temp01.dbf';
SET NEWNAME FOR DATAFILE 7 TO '+DATA/EXAMPLE_5';
SET NEWNAME FOR DATAFILE 8 TO '+DATA/INDEX_DATA_6';
restore database;
switch datafile all;
recover database;
}
17) At the end of this command, there will be an error as shown below.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at
RMAN-06054: media recovery requesting unknown archived log for thread X with sequence XX and starting
SCN of XXXX
RMAN>
18) Ignore this error because it is looking for the archivelog. Exit from the RMAN prompt.
19) Now If you DON’T WANT TO CHANGE THE NAME OF THE DATABASE, then run open resetlog
command.
SQL> alter database open resetlogs;
Database altered.
20) If you WANT TO CHANGE THE DATABASE NAME TO NEW ONE, open a new session & complete below steps.
SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE AS '/tmp/control.trc';;
21) Now open this trace file in vi editor & change the name of the database to the desired one, save the file with .sql extension.
22) Now run the newly modified controlfile.sql on the newly restored database
SQL> @/tmp/control.sql
23) Now open the database with resetlog option as shown below.
SQL> alter database open resetlogs
No comments:
Post a Comment