Tuesday 22 March 2016

Cloning of Database using RMAN in ASM In another Diskgroup


Cloning of Database includes below mentioned steps :-


1. Take a fresh backup of your OLD database of which you want to make a clone.

2. Create a pfile for OLD database.
SQL> create pfile=''/u01/asm1/initasmnew.ora' from spfile;

Modify the parameters in green colour of this pfile according to the New Database server.
*.compatible='11.2.0.0.0'
*.control_files='+NEWDATA/asmnew/controlfile/current.281.907165777'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='asm2'
*.db_unique_name=’asmnew
*.db_recovery_file_dest='/u01/asm1'
*.db_recovery_file_dest_size=9437184000
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=asm2XDB)'
*.open_cursors=300
*.pga_aggregate_target=104857600
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=314572800
*.undo_tablespace='UNDOTBS1'



SQL> !rman target /

RMAN> backup device type disk format '/ u01/asm1/ASM2/database_format%u' database;

RMAN> backup device type disk format '/ u01/asm1/ASM2/arch_format%u' archivelog all;



ANOTHER TERMINAL

[oracle@oracleasm1 Desktop]$ export ORACLE_SID=asmnew
[oracle@oracleasm1 Desktop]$ rlwrap sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 22 15:09:03 2016

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.


3. Use the above pfile to startup in nomount mode the NEW database. 

SQL> startup nomount pfile='/u01/asm1/initasmnew.ora' ;


4. Restore control files of OLD database to new host database.
RMAN> restore controlfile from '/u01/asm1/ASM2/autobackup/2016_03_22/o1_mf_s_907167734_ch24901d_.bkp';


5. Mount your New Database.

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

6. Catalog all Backup pieces of OLD database server to new database server

RMAN> catalog backuppiece '/u01/asm1/ASM2/backupset/2016_03_22/o1_mf_nnndf_TAG20160322T150047_ch2467rc_.bkp';


Recovery Manager: Release 11.2.0.1.0 - Production on Tue Mar 22 15:19:55 2016
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved. 
connected to target database: ASM2 (DBID=3723596112, not open)

7. Run the restore command to restore the datafiles.
TO run restore command you need the details of the datafiles of OLD database.

Login into the OLD database and get below mentioned details:-

SQL> Select file_id,file_name from dba_data_files

RMAN> run {
2> set newname for datafile 1 to '+NEWDATA' ;
3> set newname for datafile 2 to '+NEWDATA' ;
4> set newname for datafile 3 to '+NEWDATA' ;
5> set newname for datafile 4 to '+NEWDATA' ;
6> restore database ;
7> switch datafile all;
8> }

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 22-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=23 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to +NEWDATA
channel ORA_DISK_1: restoring datafile 00002 to +NEWDATA
channel ORA_DISK_1: restoring datafile 00003 to +NEWDATA
channel ORA_DISK_1: restoring datafile 00004 to +NEWDATA
channel ORA_DISK_1: reading from backup piece /u01/asm1/ASM2/backupset/2016_03_22/o1_mf_nnndf_TAG20160322T150047_ch2467rc_.bkp
channel ORA_DISK_1: piece handle=/u01/asm1/ASM2/backupset/2016_03_22/o1_mf_nnndf_TAG20160322T150047_ch2467rc_.bkp tag=TAG20160322T150047
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:56
Finished restore at 22-MAR-16

datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=907169129 file name=+NEWDATA/asmnew/datafile/system.264.907168953
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=907169129 file name=+NEWDATA/asmnew/datafile/sysaux.265.907168953
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=907169129 file name=+NEWDATA/asmnew/datafile/undotbs1.266.907168955
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=907169129 file name=+NEWDATA/asmnew/datafile/users.267.907168955

8. Recover the Database
RMAN> recover database ;

Starting recover at 22-MAR-16
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 5 is already on disk as file /u01/asm1/ASM2/archivelog/2016_03_22/o1_mf_1_5_ch248wr9_.arc
archived log for thread 1 with sequence 6 is already on disk as file +DATA/asm2/onlinelog/group_3.284.907165799
archived log file name=/u01/asm1/ASM2/archivelog/2016_03_22/o1_mf_1_5_ch248wr9_.arc thread=1 sequence=5
archived log file name=+DATA/asm2/onlinelog/group_3.284.907165799 thread=1 sequence=6
media recovery complete, elapsed time: 00:00:10
Finished recover at 22-MAR-16

RMAN> exit


Recovery Manager complete.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+NEWDATA/asmnew/datafile/system.264.907168953
+NEWDATA/asmnew/datafile/sysaux.265.907168953
+NEWDATA/asmnew/datafile/undotbs1.266.907168955
+NEWDATA/asmnew/datafile/users.267.907168955

9. Rename the ONLINE redo logs file
Rename all logfiles :-

SQL> alter database rename file '+DATA/asm2/onlinelog/group_1.282.907165781' to '+NEWDATA/asmnew/redo01.log';

SQL> alter database rename file '+DATA/asm2/onlinelog/group_2.283.907165791' to
  2  '+NEWDATA/asmnew/redo02.log';

SQL> alter database rename file '+DATA/asm2/onlinelog/group_3.284.907165799' to
  2  '+NEWDATA/asmnew/redo03.log';

SQL> alter database rename file '/u01/asm1/ASM2/onlinelog/o1_mf_3_ch22dpy1_.log' to '+NEWDATA/asmnew/redo04.log';
Database altered.
SQL> alter database rename file '/u01/asm1/ASM2/onlinelog/o1_mf_2_ch22ddxp_.log' to '+NEWDATA/asmnew/redo05.log';
Database altered.

SQL> alter database rename file '/u01/asm1/ASM2/onlinelog/o1_mf_1_ch22d59l_.log' to '+NEWDATA/asmnew/redo06.log' ;
Database altered.


SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+NEWDATA/asmnew/redo03.log
+NEWDATA/asmnew/redo04.log
+NEWDATA/asmnew/redo02.log
+NEWDATA/asmnew/redo05.log
+NEWDATA/asmnew/redo01.log
+NEWDATA/asmnew/redo06.log

6 rows selected.


SQL> alter database open resetlogs;

Database altered.

SQL> select name from v$database;

NAME
---------
ASM2

 10. Create a New Tablespace : 

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
+DATA/asm2/tempfile/temp.285.907165833

SQL> create temporary tablespace temp1 tempfile '+NEWDATA';

Tablespace created.

SQL> alter database default temporary tablespace temp1;

Database altered.

SQL>


3 comments: