From 11gR2 oracle introduced new options for “SET NEWNAME” command.
1.SET NEWNAME FOR DATAFILE and SET NEWNAME FOR TEMPFILE
2.SET NEWNAME FOR TABLESPACE
3.SET NEWNAME FOR DATABASE
The following variables are introduced for SET NEWNAME from 11gR2 :-
%b The file name remains same as the original. For example, if a datafile is named D:\oracle\oradata\matrix\test.dbf, then %b results in test.dbf.
%f Specifies the absolute file number of the datafile for which the new name is generated.
%I Specifies the DBID.
%N Specifies the tablespace name.
%U Specifies the following format: data-D-%d_id-%I_TS-%N_FNO-%f.
Time to test 🙂
In my test, i am creating a duplicate database ORCL, from the rman backup of MATRIX database. As i am doing it on Windows box, i do hit ORA-600 [KSMFPG5], [0xAEC0000], which is a bug, and also mentioned in one of my previous blog.
1. taking backup of matrix database –
RMAN> run{ 2> backup database format 'D:\oracle\backup\matrix\%d_%s_%p'; 3> backup archivelog all format 'D:\oracle\backup\matrix\arc_%d_%s_%p'; 4> } Starting backup at 11-JAN-12 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=D:\ORACLE\ORADATA\MATRIX\SYSTEM01.DBF .............. channel ORA_DISK_1: finished piece 1 at 11-JAN-12 piece handle=D:\ORACLE\BACKUP\MATRIX\ARC_MATRIX_10_1 tag=TAG20120111T133016 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07 Finished backup at 11-JAN-12
The database as well as the archivelog backupset exist in D:\ORACLE\BACKUP\MATRIX\
2. Duplicating db MATRIX to ORCL. Before executing the command, created ORCL pfile , passwordfile and windows service using oradim utility.
D:\scripts>set oracle_sid=ORCL D:\scripts>sqlplus / as sysdba SQL*Plus: Release 11.2.0.2.0 Production on Wed Jan 11 13:32:14 2012 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance ORACLE instance started. Total System Global Area 150667264 bytes Fixed Size 1382112 bytes Variable Size 92277024 bytes Database Buffers 50331648 bytes Redo Buffers 6676480 bytes SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options D:\scripts> D:\scripts> D:\scripts>rman auxiliary / Recovery Manager: Release 11.2.0.2.0 - Production on Wed Jan 11 13:33:02 2012 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to auxiliary database: ORCL (not mounted) RMAN> run { 2> 3> SET NEWNAME FOR DATABASE TO 'D:\oracle\oradata\orcl\%b'; 4> SET NEWNAME FOR TEMPFILE 1 TO 'D:\oracle\oradata\orcl\temp01.dbf' ; 5> 6> DUPLICATE DATABASE 'MATRIX' DBID 2312606933 7> TO ORCL 8> BACKUP LOCATION 'D:\oracle\backup\matrix' 9> LOGFILE 10> GROUP 1 ('D:\oracle\oradata\orcl\redo01a.log', 11> 'D:\oracle\oradata\orcl\redo01b.log') SIZE 50M REUSE, 12> GROUP 2 ('D:\oracle\oradata\orcl\redo02a.log', 13> 'D:\oracle\oradata\orcl\redo02b.log') SIZE 50M REUSE, 14> GROUP 3 ('D:\oracle\oradata\orcl\redo03a.log', 15> 'D:\oracle\oradata\orcl\redo03b.log') SIZE 50M REUSE; 16> }
executing command: SET NEWNAME executing command: SET NEWNAME Starting Duplicate Db at 11-JAN-12 contents of Memory Script: { sql clone "alter system set db_name = ''MATRIX'' comment= ''Modified by RMAN duplicate'' scope=spfile"; sql clone "alter system set db_unique_name = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile"; shutdown clone immediate; startup clone force nomount restore clone primary controlfile from 'D:\ORACLE\BACKUP\matrix\MATRIX_9_1'; alter clone database mount; } executing Memory Script sql statement: alter system set db_name = ''MATRIX'' comment= ''Modified by RMAN duplicate'' scope=spfile sql statement: alter system set db_unique_name = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile Oracle instance shut down Oracle instance started Total System Global Area 150667264 bytes Fixed Size 1382112 bytes Variable Size 92277024 bytes Database Buffers 50331648 bytes Redo Buffers 6676480 bytes Starting restore at 11-JAN-12 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=130 device type=DISK channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 output file name=D:\ORACLE\ORADATA\ORCL\CONTROL01.CTL output file name=D:\ORACLE\ORADATA\ORCL\CONTROL02.CTL Finished restore at 11-JAN-12 database mounted released channel: ORA_AUX_DISK_1 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=130 device type=DISK contents of Memory Script: { set until scn 859591; set newname for datafile 1 to "D:\oracle\oradata\orcl\SYSTEM01.DBF"; set newname for datafile 2 to "D:\oracle\oradata\orcl\SYSAUX01.DBF"; set newname for datafile 3 to "D:\oracle\oradata\orcl\UNDOTBS01.DBF"; set newname for datafile 4 to "D:\oracle\oradata\orcl\USERS01.DBF"; set newname for datafile 5 to "D:\oracle\oradata\orcl\EXAMPLE01.DBF"; 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 11-JAN-12 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 D:\oracle\oradata\orcl\SYSTEM01.DBF channel ORA_AUX_DISK_1: restoring datafile 00002 to D:\oracle\oradata\orcl\SYSAUX01.DBF channel ORA_AUX_DISK_1: restoring datafile 00003 to D:\oracle\oradata\orcl\UNDOTBS01.DBF channel ORA_AUX_DISK_1: restoring datafile 00004 to D:\oracle\oradata\orcl\USERS01.DBF channel ORA_AUX_DISK_1: restoring datafile 00005 to D:\oracle\oradata\orcl\EXAMPLE01.DBF channel ORA_AUX_DISK_1: reading from backup piece D:\ORACLE\BACKUP\MATRIX\MATRIX_8_1 channel ORA_AUX_DISK_1: piece handle=D:\ORACLE\BACKUP\MATRIX\MATRIX_8_1 tag=TAG20120111T132903 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05 Finished restore at 11-JAN-12 contents of Memory Script: { switch clone datafile all; } executing Memory Script datafile 1 switched to datafile copy input datafile copy RECID=6 STAMP=772292110 file name=D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF datafile 2 switched to datafile copy input datafile copy RECID=7 STAMP=772292110 file name=D:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF datafile 3 switched to datafile copy input datafile copy RECID=8 STAMP=772292110 file name=D:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF datafile 4 switched to datafile copy input datafile copy RECID=9 STAMP=772292110 file name=D:\ORACLE\ORADATA\ORCL\USERS01.DBF datafile 5 switched to datafile copy input datafile copy RECID=10 STAMP=772292111 file name=D:\ORACLE\ORADATA\ORCL\EXAMPLE01.DBF contents of Memory Script: { set until scn 859591; recover clone database delete archivelog ; } executing Memory Script executing command: SET until clause Starting recover at 11-JAN-12 using channel ORA_AUX_DISK_1 starting media recovery channel ORA_AUX_DISK_1: starting archived log restore to default destination channel ORA_AUX_DISK_1: restoring archived log archived log thread=1 sequence=10 channel ORA_AUX_DISK_1: reading from backup piece D:\ORACLE\BACKUP\MATRIX\ARC_MATRIX_10_1 channel ORA_AUX_DISK_1: piece handle=D:\ORACLE\BACKUP\MATRIX\ARC_MATRIX_10_1 tag=TAG20120111T133016 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03 archived log file name=D:\ORACLE\ARCHIVELOG\ORCL\ORCL_0000000010_0772282200_0001.ARC thread=1 sequence=10 channel clone_default: deleting archived log(s) archived log file name=D:\ORACLE\ARCHIVELOG\ORCL\ORCL_0000000010_0772282200_0001.ARC RECID=1 STAMP=772292118 media recovery complete, elapsed time: 00:00:03 Finished recover at 11-JAN-12 Oracle instance started Total System Global Area 150667264 bytes Fixed Size 1382112 bytes Variable Size 92277024 bytes Database Buffers 50331648 bytes Redo Buffers 6676480 bytes contents of Memory Script: { sql clone "alter system set db_name = ''ORCL'' comment= ''Reset to original value by RMAN'' scope=spfile"; sql clone "alter system reset db_unique_name scope=spfile"; shutdown clone immediate; } executing Memory Script sql statement: alter system set db_name = ''ORCL'' comment= ''Reset to original value by RMAN'' scope=spfile sql statement: alter system reset db_unique_name scope=spfile Oracle instance shut down RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of Duplicate Db command at 01/11/2012 13:36:16 RMAN-05501: aborting duplication of target database RMAN-04014: startup failed: ORA-00600: internal error code, arguments: [17099], [], [], [], [], [], [], [], [], [], [], [] ORA-00600: internal error code, arguments: [KSMFPG5], [0xAEC0000], [], [], [], [], [], [], [], [], [], [] RMAN> exit
For the ORA-600, recreated the controlfile, opened the database using RESETLOGS option and added temp file.
In earlier versions of oracle we had to mention SET NEWNAME command to rename the duplicate datafiles while restoring/duplicating the database, where we mentioned it for each and every datafile.
# set new filenames for the datafiles
SET NEWNAME FOR DATAFILE 1 TO ‘/dup/oracle/oradata/trgt/system01.dbf’;
SET NEWNAME FOR DATAFILE 2 TO ‘/dup/oracle/oradata/trgt/undotbs01.dbf’;
From 11gR2 simply using SET NEWNAME FOR DATABASE has made things easier.