Please see my other blog for Oracle EBusiness Suite Posts - EBMentors

Search This Blog

Note: All the posts are based on practical approach avoiding lengthy theory. All have been tested on some development servers. Please don’t test any post on production servers until you are sure.

Wednesday, May 29, 2013

Restore RMAN RAC database backup to other RAC enviornment

Scenerio:
We have a disk backup of a 2 nodes RAC database (homedb) and want to restore it to other RAC environment 2 nodes.
Environment:
Source: Oracle RAC 11gR2 11.2.0.3 (Windows 2008R2) , Diskgroups:  +HOMEDBDATA & +HOMEDBFLASH, Instances: homedb1,homedb2

Destination:  Oracle RAC 11gR2 11.2.0.3 (Windows 2008R2) only software installed. No database existing. Diskgroups: +DBDATA & +DBFLASH


Backup on Source 
Take backup on source RAC environment (eg; took backup on the node1 192.168.31.48)
and copy it to the destination environment (eg; 192.168.62.11). Know the DB ID.
RUN {
ALLOCATE CHANNEL ch00 TYPE DISK FORMAT 'D:\rmanbackup\db\%d_DB_%u_%s_%p';
set controlfile autobackup format for device type disk to "D:\rmanbackup\ctl\cf_homedb.%F";
backup
filesperset 4
INCREMENTAL LEVEL 0 AS COMPRESSED BACKUPSET database;
sql "alter system archive log current";
release channel ch00;
ALLOCATE CHANNEL CH01 TYPE DISK FORMAT 'D:\RMANBACKUP\AR\al_%U';
backup
filesperset 4
AS COMPRESSED BACKUPSET archivelog all;
RELEASE CHANNEL CH01;
}

 
Restore/Recover Database
Database will be restored and recovered as single instance first using ASM on any node of the destination enviornment (eg; node1 in my example)
 

1)  on destination (eg; 192.168.62.11) , make parameter file (disable FRA), create the instance and start up in nomount state using RMAN.

inithomedb.ora
large_pool_size=100m
shared_pool_size=1024m
db_cache_size=300m
audit_file_dest='D:\app\inam\admin\homedb\adump'
audit_trail='db'
compatible='11.2.0.0.0'
control_files='+dbdata/homedb/controlfile/control01.ctl'
db_block_size=8192
db_domain=''
db_name='homedb'
#db_recovery_file_dest='+DBFLASH'
#db_recovery_file_dest_size=10G
diagnostic_dest='D:\app\inam'
remote_login_passwordfile='exclusive'

C:\Users\inam>set oracle_sid=homedb

C:\Users\inam>oradim -new -sid homedb
Instance created.


C:\Users\inam>rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Sun May 26 11:47:35 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> set dbid 1547250382

executing command: SET DBID

RMAN> startup nomount pfile='d:\rmanbackup\inithomedb.ora';

Oracle instance started

Total System Global Area    1553379328 bytes

Fixed Size                     2255464 bytes
Variable Size               1224738200 bytes
Database Buffers             318767104 bytes
Redo Buffers                   7618560 bytes


2) Create the related folders (as you have on your source for your db) on ASM using asmcmd and restore the control file on your diskgroup. Check first preview option. Then mount the database.
RMAN> restore controlfile to '+dbdata/homedb/controlfile/control01.ctl' from 'D:\rmanbackup\ctl\CF_homedb.C-1547250382-20130527-05' preview;
Starting restore at 28-MAY-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=659 device type=DISK

Finished restore at 28-MAY-13

RMAN> restore controlfile to '+dbdata/homedb/controlfile/control01.ctl' from 'D:\rmanbackup\ctl\CF_homedb.C-1547250382-20130527-05';

Starting restore at 28-MAY-13
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 28-MAY-1
3

Verify using asmcmd
ASMCMD> pwd
+dbdata/homedb/controlfile
ASMCMD> ls
control01.ctl
current.305.816437125

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

3) After mount check the backup information now, you will see the information as source had

RMAN> list backup;
RMAN>  list backup summary;
RMAN> list backup of archivelog all; -- see the last SCN
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
6663    37.35M     DISK        00:00:08     27-MAY-13
        BP Key: 6680   Status: AVAILABLE  Compressed: YES  Tag: TAG20130527T092913
        Piece Name: D:\RMANBACKUP\AR\AL_T9OAM139_1_1

  List of Archived Logs in backup set 6663
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    30908   2214627331 27-MAY-13 2214803334 27-MAY-13
  1    30909   2214803334 27-MAY-13 2214806534 27-MAY-13
  2    28345   2214627466 27-MAY-13 2214803402 27-MAY-13
  2    28346   2214803402 27-MAY-13 2214806551 27-MAY-13

4) Get the list of all datafiles to be used in RMAN script to set the new location (new diskgroup on destination environment)


RMAN> sql 'select file#,name from v$datafile';


5) Restore the database now, use the set new name for all datafiles retrieved in step 5.
run {
ALLOCATE CHANNEL ch00 device TYPE DISK;
#set until SCN 2214806551;
set newname for datafile 1 to '+DBDATA';
set newname for datafile 2 to '+DBDATA';
set newname for datafile 3 to '+DBDATA';
set newname for datafile 4 to '+DBDATA';
set newname for datafile 5 to '+DBDATA';
set newname for datafile 6 to '+DBDATA';
set newname for datafile 7 to '+DBDATA';
set newname for datafile 8 to '+DBDATA';
set newname for datafile 9 to '+DBDATA';
set newname for datafile 10 to '+DBDATA';
set newname for datafile 11 to '+DBDATA';
set newname for datafile 12 to '+DBDATA';
set newname for datafile 13 to '+DBDATA';
set newname for datafile 14 to '+DBDATA';
set newname for datafile 15 to '+DBDATA';
set newname for datafile 16 to '+DBDATA';
set newname for datafile 17 to '+DBDATA';
restore database;
switch datafile all;
RELEASE CHANNEL ch00;
}



6) set FRA now
SQL> alter system set db_recovery_file_dest_size=10G;
System altered.
SQL> alter system set db_recovery_file_dest='+DBFLASH';
System altered.

7) Now recover the database

RMAN>  recover database;


8) Open database with resetlogs option
RMAN> alter database open resetlogs;
database opened

9) Add new tempfile and remove the old one.
SQL> select name from v$tempfile;

NAME
----------------------------------------------------------------------------
+homedbDATA/homedb/tempfile/temp.263.770482269
SQL> alter tablespace temp add tempfile '+dbdata';
Tablespace altered.
SQL> select name from v$tempfile;
NAME
----------------------------------------------------------------------------
+homedbDATA/homedb/tempfile/temp.263.770482269
+DBDATA/homedb/tempfile/temp.336.816615741

Remove the first temp file.
SQL> alter tablespace temp drop tempfile '+homedbDATA/homedb/tempfile/temp.263.770482269';
Tablespace altered.
Making clustered database
Now as database (homedb) has been restored and recovered and opened succussfuly as single instance, we convert it into RAC database.

1)  Change the pfile, add all RAC related parameters.
inithomedb.ora
large_pool_size=100m
shared_pool_size=1024m
db_cache_size=300m
audit_file_dest='D:\app\inam\admin\homedb\adump'
audit_trail='db'
compatible='11.2.0.0.0'
control_files='+dbdata/homedb/controlfile/control01.ctl'
db_block_size=8192
db_domain=''
db_name='homedb'
db_recovery_file_dest='+DBFLASH'
db_recovery_file_dest_size=10G

diagnostic_dest='D:\app\inam'
remote_login_passwordfile='exclusive'
homedb1.instance_number=1
homedb2.instance_number=2
cluster_database=true
cluster_database_instances=2


2) create spfile on the shared storage, because all instances must use the same server parameter file.
SQL> create spfile='+DBDATA' from pfile='D:\rmanbackup\inithomedb.ora';
File created.


3) shutdown the single instance (homedb) now
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

4) Check the status of the new db (homedb) just to confirm its status, we already know it has not been registered as cluster database yet.
D:\app\11.2.0.3\grid\BIN>srvctl config database -d homedb
PRCD-1120 : The resource for database homedb could not be found.
PRCR-1001 : Resource ora.homedb.db does not exist

5) As it is confirmed by above command that no resource dupdb exists, now add it and its config.
D:\app\11.2.0.3\grid\BIN>srvctl add database -d homedb -o D:\app\Inam\product\11.2.0.3\dbhome_1

Check DB config after adding database
D:\app\11.2.0.3\grid\BIN>srvctl config database -d homedb
Database unique name: homedb
Database name:
Oracle home: D:\app\Inam\product\11.2.0.3\dbhome_1
Oracle user: nt authority\system
Spfile:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: homedb
Database instances:
Disk Groups:
Mount point paths:
Services:
Type: RAC
Database is administrator managed

6) Now add RAC instances
D:\app\11.2.0.3\grid\BIN>srvctl add instance -d homedb -i homedb1 -n or-11
D:\app\11.2.0.3\grid\BIN>srvctl add instance -d homedb -i homedb2 -n or-12
D:\app\11.2.0.3\grid\BIN>srvctl config database -d homedb
Database unique name: homedb
Database name:
Oracle home: D:\app\Inam\product\11.2.0.3\dbhome_1
Oracle user: nt authority\system
Spfile:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: homedb
Database instances: homedb1,homedb2
Disk Groups:
Mount point paths:
Services:
Type: RAC
Database is administrator managed

7)  Now create the parameter files on both nodes, first check the parameter file name via asmcmd on shared storage that we created earlier to know its name.
ASMCMD> pwd
+dbdata/homedb/parameterfile
ASMCMD> ls
spfile.337.816612265

Create inithomedb1.ora and inithomedb2.ora on both nodes with below line
SPFILE='+dbdata/homedb/parameterfile/spfile.337.816612265'


8) Now start the database and check on both nodes
D:\app\11.2.0.3\grid\BIN>srvctl start database -d homedb
D:\app\11.2.0.3\grid\BIN>srvctl config database -d homedb
Database unique name: homedb
Database name:
Oracle home: D:\app\Inam\product\11.2.0.3\dbhome_1
Oracle user: nt authority\system
Spfile:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: homedb
Database instances: homedb1,homedb2
Disk Groups: DBDATA,DBFLASH
Mount point paths:
Services:
Type: RAC
Database is administrator managed

set oracle_sid=homedb1
sqlplus / as sysdba
SQL> select Inst_id,instance_name from gv$instance;

   INST_ID INSTANCE_NAME
---------- ----------------
         1 homedb1
         2 homedb2

1 comment:

Rehan said...

is it necessary to give full path
restore controlfile to '+dbdata/homedb/controlfile/control01.ctl' ...... what will happen if we simply write restore controlfile to '+dbdata/'