step by step restore rman to different host

7

Click here to load reader

Upload: osama-mustafa

Post on 13-May-2015

7.075 views

Category:

Technology


1 download

DESCRIPTION

Step by Step Restore RMAN to New Host Twitter : @osamaoracle

TRANSCRIPT

Page 1: Step by Step Restore rman to different host

Restore RMAN to New Host

Osama Mustafa Page 1

Steps On Source Database

**Most Of work will be done on target database

1- Get DBID By Using The below :

SQL > Select Db_id from v$database ;

Or

RMAN target /

2- Get the last SCN On Database since we will not have active redolog using the below

document :

SQL > select max(next_change#) from v$archived_log where archived = 'YES' group by

thread#;

Or Using RMAN:

RMAN> list backup of archivelog all;

Page 2: Step by Step Restore rman to different host

Restore RMAN to New Host

Osama Mustafa Page 2

3- Take Backup Using RMAN :

run {

allocate channel d1 type disk format 'YOUR-PATH/Database_%U;

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

BACKUP DATABASE PLUS ARCHIVELOG;

backup current controlfile format 'YOUR_PATH/controlfile_%U';

release channel c1;

release channel c2;

release channel c3;

}

Now move all generated backup file to the new host with the same directory for example if you

backup on folder /u01/app then on new host should be the same.

Page 3: Step by Step Restore rman to different host

Restore RMAN to New Host

Osama Mustafa Page 3

Steps On New Server

After copy file do the below steps:

1- export ORACLE_SID=SID_SAME_AS_PROD

RMAN TARGET /

RMAN > set dbid <as you get it from above query>;

RMAN > Startup nomount;

RMAN > restore spfile to pfile '/u01/app/oracle/oradata/orcl/initorcl.ora' from

autobackup;

RMAN> shutdown abort;

Now you have to edit SPFile ;

*.audit_file_dest=’LOCATION’

*.control_files=’LOCATION’

*.db_recovery_file_dest_size=Size

*.db_recovery_file_dest=’LOCATION’

*.diagnostic_dest=’LOCATION’

*.log_archive_dest_1='LOCATION=LOCATION’

*.local_listener='LISTENER_ORCL'

Page 4: Step by Step Restore rman to different host

Restore RMAN to New Host

Osama Mustafa Page 4

RMAN> startup nomount pfile='/u01/app/oracle/oradata/orcl/initorcl.ora';

RMAN> restore controlfile from autobackup;

RMAN> alter database mount;

Note: now you have 2 options 1 - move the backup to same location on target server 2- Copy

Backup to any location but you need to use CATALOG Command check below :

RMAN> catalog start with 'Where You copy Backup';

You are almost Done, You have But before restore database you can move datafile to any

location using (all the below steps on RMAN ) But

Remember don't run the below yet:

SET NEWNAME FOR DATAFILE 1 TO '/u01/app/oracle/oradata/orcl/system01.dbf';

SET NEWNAME FOR DATAFILE 2 TO '/u01/app/oracle/oradata/orcl/sysaux01.dbf';

SET NEWNAME FOR DATAFILE 3 TO '/u01/app/oracle/oradata/orcl/undotbs01.dbf';

SET NEWNAME FOR DATAFILE 4 TO '/u01/app/oracle/oradata/orcl/users01.dbf';

SET NEWNAME FOR DATAFILE 5 TO '/u01/app/oracle/oradata/orcl/example01.dbf';

SET NEWNAME FOR DATAFILE 6 TO '/u01/app/oracle/oradata/orcl/test.dbf';

SET NEWNAME FOR DATAFILE 7 TO '/u01/app/oracle/oradata/orcl/dbfs01.dbf';

**Note: After TO: New Location.

Page 5: Step by Step Restore rman to different host

Restore RMAN to New Host

Osama Mustafa Page 5

SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo01.log'' TO

''/u01/app/oracle/oradata/orcl/redo/redo01.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo02.log'' TO

''/u01/app/oracle/oradata/orcl/redo/redo02.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo03.log'' TO

''/u01/app/oracle/oradata/orcl/redo/redo03.log'' ";

Are you still having SCN that we see it above :)

Ok Now you RMAN Script will looks like below

RUN {

SET NEWNAME FOR DATAFILE 1 TO '/u01/app/oracle/oradata/orcl/system01.dbf';

SET NEWNAME FOR DATAFILE 2 TO '/u01/app/oracle/oradata/orcl/sysaux01.dbf';

SET NEWNAME FOR DATAFILE 3 TO '/u01/app/oracle/oradata/orcl/undotbs01.dbf';

SET NEWNAME FOR DATAFILE 4 TO '/u01/app/oracle/oradata/orcl/users01.dbf';

SET NEWNAME FOR DATAFILE 5 TO '/u01/app/oracle/oradata/orcl/example01.dbf';

SET NEWNAME FOR DATAFILE 6 TO '/u01/app/oracle/oradata/orcl/test.dbf';

SET NEWNAME FOR DATAFILE 7 TO '/u01/app/oracle/oradata/orcl/dbfs01.dbf';

SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo01.log'' TO

''/u01/app/oracle/oradata/orcl/redo/redo01.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo02.log'' TO

''/u01/app/oracle/oradata/orcl/redo/redo02.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo03.log'' TO

''/u01/app/oracle/oradata/orcl/redo/redo03.log'' ";

Page 6: Step by Step Restore rman to different host

Restore RMAN to New Host

Osama Mustafa Page 6

SET UNTIL SCN <ABOVE_QUERY>;

ESTORE DATABASE;

SWITCH DATAFILE ALL;

RECOVER DATABASE;

}

Sqlplus / as sysdba

SQL > Alter database open Resetlogs ;

Thank you

Osama Mustafa

http://osamamustafa.blogspot.com

Twitter: @OsamaOracle

Page 7: Step by Step Restore rman to different host

Restore RMAN to New Host

Osama Mustafa Page 7