06 July 2011

Clone ASM Database using RMAN

Pre-steps:


Backup target database

Make sure have enough memory, space in OS

Actual steps:

1. Create Directories needed for Auxiliary instance

[oracle@eprax01 rdbms]$ pwd

/u01/app/oracle/diag/rdbms

[oracle@eprax01 rdbms]$ mkdir dev

[oracle@eprax01 rdbms]$ ls

dev prd

[oracle@eprax01 rdbms]$ cd dev/

[oracle@eprax01 dev]$ mkdir bdump udump pfile trace

[oracle@eprax01 dev]$ ls

bdump pfile trace udump



2. Copy Target init.ora to the AUX instance location(dev in our case)

Note that we have spfile used and hence we first need to get pfile from spfile

SQL> sho parameter spfile;

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

spfile string +DATA/prd/spfileprd.ora

SQL> create pfile from spfile;

File created.

3. Copy the initprd.ora to initdev.ora and make necessary changes related to DEV instance.

[oracle@eprax01 dbs]$ cp -p initprd.ora initdev.ora

You can use different Diskgroup if you like (Which you should); I have used the same Disk group.

The init.ora may look like this:

*.audit_file_dest='/u01/app/oracle/admin/dev/adump'

*.audit_trail='db'

*.compatible='11.2.0.0.0'

*.control_files='+DATA/dev/controlfile/current.261.755015849','+DATA/dev/controlfile/current.260.755015851'

*.db_block_size=8192

*.db_create_file_dest='+DATA'

*.db_domain=''

*.db_name='dev'

*.db_recovery_file_dest_size=4039114752

*.db_recovery_file_dest='+ARCH'

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=devXDB)'

*.memory_target=364904448

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_tablespace='UNDOTBS1'

*.db_file_name_convert=('+DATA/prd','+DATA/dev')  Use this most importantly


*.log_file_name_convert=('+DATA/prd','+DATA/dev')  Use this most importantly

*.instance_name='dev'

4. Build password file for DEV instance.

[oracle@eprax01 dbs]$ orapwd file=/u01/app/oracle/product/11.2.0/dbs/orapwdev password=dba123 entries=10

5. Start DEV(AUXILIARY instance) in nomount state

SQL> startup nomount pfile=/u01/app/oracle/product/11.2.0/dbs/initdev.ora;

ORACLE instance started.

Total System Global Area 364081152 bytes

Fixed Size 1336568 bytes

Variable Size 289409800 bytes

Database Buffers 67108864 bytes

Redo Buffers 6225920 bytes


6. Add entries in Listener and TNSNAMES .ora

DEV =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = eprax01)(PORT = 1523))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = dev)

)

)


7. Connect to target database and auxiliary

[oracle@eprax01 admin]$ rman target sys/XXXXX@prd auxiliary / - Please connect Auxiliary database locally and connect to Target database remotely using services. Otherwise we end-up getting the below error:

RMAN-04006: error from auxiliary database: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

To avoid this, Set Oracle SID as AUX database(in our case DEV) and then logon to RMAN as shown below:

[oracle@eprax01 ~]$ rman target sys/XXXXX@prd auxiliary /


Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jul 6 15:22:05 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRD (DBID=1818679464)
connected to auxiliary database: DEV (not mounted)

RMAN> duplicate target database to dev;
Starting Duplicate Db at 06-JUL-11
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=23 device type=DISK

contents of Memory Script:

{

sql clone "create spfile from memory";

}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script:

{
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 364081152 bytes
Fixed Size 1336568 bytes
Variable Size 293604104 bytes
Database Buffers 62914560 bytes
Redo Buffers 6225920 bytes

contents of Memory Script:
{
sql clone "alter system set control_files =

''+DATA/dev/controlfile/current.283.755796269'', ''+DATA/dev/controlfile/current.284.755796269'' comment=

''Set by RMAN'' scope=spfile";

sql clone "alter system set db_name =

''PRD'' comment=

''Modified by RMAN duplicate'' scope=spfile";

sql clone "alter system set db_unique_name =

''DEV'' comment=

''Modified by RMAN duplicate'' scope=spfile";

shutdown clone immediate;

startup clone force nomount

restore clone primary controlfile;

alter clone database mount;

}

executing Memory Script

sql statement: alter system set control_files = ''+DATA/dev/controlfile/current.283.755796269'', ''+DATA/dev/controlfile/current.284.755796269'' comment= ''Set by RMAN'' scope=spfile
sql statement: alter system set db_name = ''PRD'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set db_unique_name = ''DEV'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area 364081152 bytes
Fixed Size 1336568 bytes
Variable Size 293604104 bytes
Database Buffers 62914560 bytes
Redo Buffers 6225920 bytes

Starting restore at 06-JUL-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=22 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file

channel ORA_AUX_DISK_1: reading from backup piece +ARCH/prd/autobackup/2011_07_06/s_755788909.275.755788911

channel ORA_AUX_DISK_1: piece handle=+ARCH/prd/autobackup/2011_07_06/s_755788909.275.755788911 tag=TAG20110706T132149

channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:09
output file name=+DATA/dev/controlfile/current.283.755796269
output file name=+DATA/dev/controlfile/current.284.755796269

Finished restore at 06-JUL-11
database mounted

RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.
contents of Memory Script:

{

set until scn 1258875;

set newname for datafile 1 to

"+data";

set newname for datafile 2 to

"+data";

set newname for datafile 3 to

"+data";

set newname for datafile 4 to

"+data";

set newname for datafile 5 to

"+data";

restore

clone database

;

}

executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME

Starting restore at 06-JUL-11
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00001 to +data

channel ORA_AUX_DISK_1: restoring datafile 00002 to +data

channel ORA_AUX_DISK_1: restoring datafile 00003 to +data

channel ORA_AUX_DISK_1: restoring datafile 00004 to +data

channel ORA_AUX_DISK_1: restoring datafile 00005 to +data

channel ORA_AUX_DISK_1: reading from backup piece +ARCH/prd/backupset/2011_07_06/nnndf0_tag20110706t132104_0.272.755788867

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:16

Finished restore at 06-JUL-11

contents of Memory Script:

{

switch clone datafile all;

}

executing Memory Script

datafile 1 switched to datafile copy

input datafile copy RECID=7 STAMP=755796410 file name=+DATA/dev/datafile/system.285.755796333

datafile 2 switched to datafile copy

input datafile copy RECID=8 STAMP=755796410 file name=+DATA/dev/datafile/sysaux.286.755796337

datafile 3 switched to datafile copy

input datafile copy RECID=9 STAMP=755796410 file name=+DATA/dev/datafile/undotbs1.288.755796343

datafile 4 switched to datafile copy

input datafile copy RECID=10 STAMP=755796410 file name=+DATA/dev/datafile/users.289.755796343

datafile 5 switched to datafile copy

input datafile copy RECID=11 STAMP=755796411 file name=+DATA/dev/datafile/example.287.755796341

contents of Memory Script:

{

set until scn 1258875;

recover

clone database

delete archivelog

;

}

executing Memory Script
executing command: SET until clause

Starting recover at 06-JUL-11

using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 23 is already on disk as file +ARCH/prd/archivelog/2011_07_06/thread_1_seq_23.273.755788903

archived log for thread 1 with sequence 24 is already on disk as file +ARCH/prd/archivelog/2011_07_06/thread_1_seq_24.276.755791611

archived log for thread 1 with sequence 25 is already on disk as file +ARCH/prd/archivelog/2011_07_06/thread_1_seq_25.277.755795985

archived log file name=+ARCH/prd/archivelog/2011_07_06/thread_1_seq_23.273.755788903 thread=1 sequence=23

archived log file name=+ARCH/prd/archivelog/2011_07_06/thread_1_seq_24.276.755791611 thread=1 sequence=24

archived log file name=+ARCH/prd/archivelog/2011_07_06/thread_1_seq_25.277.755795985 thread=1 sequence=25

media recovery complete, elapsed time: 00:00:08

Finished recover at 06-JUL-11

contents of Memory Script:

{

shutdown clone immediate;

startup clone nomount;

sql clone "alter system set db_name =

''DEV'' comment=

''Reset to original value by RMAN'' scope=spfile";

sql clone "alter system reset db_unique_name scope=spfile";

shutdown clone immediate;

startup clone nomount;

}

executing Memory Script


database dismounted

Oracle instance shut down



connected to auxiliary database (not started)

Oracle instance started


Total System Global Area 364081152 bytes

Fixed Size 1336568 bytes

Variable Size 293604104 bytes

Database Buffers 62914560 bytes

Redo Buffers 6225920 bytes

sql statement: alter system set db_name = ''DEV'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset db_unique_name scope=spfile

Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 364081152 bytes
Fixed Size 1336568 bytes
Variable Size 293604104 bytes
Database Buffers 62914560 bytes
Redo Buffers 6225920 bytes

sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DEV" RESETLOGS ARCHIVELOG

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 292

LOGFILE

GROUP 1 ( '+data', '+data' ) SIZE 50 M REUSE,

GROUP 2 ( '+data', '+data' ) SIZE 50 M REUSE,

GROUP 3 ( '+data', '+data' ) SIZE 50 M REUSE

DATAFILE

'+DATA/dev/datafile/system.285.755796333'

CHARACTER SET AL32UTF8

contents of Memory Script:

{

set newname for tempfile 1 to

"+data";

switch clone tempfile all;

catalog clone datafilecopy "+DATA/dev/datafile/sysaux.286.755796337",

"+DATA/dev/datafile/undotbs1.288.755796343",

"+DATA/dev/datafile/users.289.755796343",

"+DATA/dev/datafile/example.287.755796341";

switch clone datafile all;

}

executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to +data in control file

cataloged datafile copy

datafile copy file name=+DATA/dev/datafile/sysaux.286.755796337 RECID=1 STAMP=755796530

cataloged datafile copy

datafile copy file name=+DATA/dev/datafile/undotbs1.288.755796343 RECID=2 STAMP=755796530

cataloged datafile copy

datafile copy file name=+DATA/dev/datafile/users.289.755796343 RECID=3 STAMP=755796531

cataloged datafile copy

datafile copy file name=+DATA/dev/datafile/example.287.755796341 RECID=4 STAMP=755796531



datafile 2 switched to datafile copy

input datafile copy RECID=1 STAMP=755796530 file name=+DATA/dev/datafile/sysaux.286.755796337

datafile 3 switched to datafile copy

input datafile copy RECID=2 STAMP=755796530 file name=+DATA/dev/datafile/undotbs1.288.755796343

datafile 4 switched to datafile copy

input datafile copy RECID=3 STAMP=755796531 file name=+DATA/dev/datafile/users.289.755796343

datafile 5 switched to datafile copy

input datafile copy RECID=4 STAMP=755796531 file name=+DATA/dev/datafile/example.287.755796341
contents of Memory Script:

{

Alter clone database open resetlogs;

}

executing Memory Script

database opened

Finished Duplicate Db at 06-JUL-11

Confirmation:

SQL> select instance_name, status from v$instance;


INSTANCE_NAME STATUS

---------------- ------------

dev OPEN

2 comments:

  1. Initialization parameter for control files in initdev.ora- yu named the files all the way to the filename. Will it be if I leave it for the OMF to name them?
    i.e '+DATA/dev/controlfile/' or just '+DATA'?

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete