Custom Search . . .

Thursday, April 28, 2011

Oracle 11g RMAN DUPLICATE DATABASE WITHOUT TARGET CONNECTION

Here is the RMAN DUPLICATE DATABASE by using without a target connection and without a recovery catalog connection. 


I hope this short example will explain you about rman duplication database. 


Here is the example:


This is my below setting in TARGET DATABASE


RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;



new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored


RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'I:\Ora-Backup\DB001\CF_%F';


new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'I:\Ora-Backup\DB001\CF_%F';
new RMAN configuration parameters are successfully stored


RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'I:\Ora-Backup\DB001\BKP_%U';


new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   'I:\Ora-Backup\DB001\BKP_%U';
new RMAN configuration parameters are successfully stored

Here is the complete full backup script on TARGET DATABASE

RMAN> run
2> {
3> backup database;
4> backup archivelog all;
5> }


Starting backup at 28-APR-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=144 device type=DISK
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=G:\ORADATA\DB001\DB001\SYSTEM01.DBF
input datafile file number=00002 name=G:\ORADATA\DB001\DB001\SYSAUX01.DBF
input datafile file number=00003 name=G:\ORADATA\DB001\DB001\UNDOTBS01.DBF
input datafile file number=00004 name=G:\ORADATA\DB001\DB001\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 28-APR-11
channel ORA_DISK_1: finished piece 1 at 28-APR-11
piece handle=I:\ORA-BACKUP\DB001\BKP_01MAU0UD_1_1 tag=TAG20110428T165432 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
Finished backup at 28-APR-11


Starting backup at 28-APR-11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=1 STAMP=749667205
input archived log thread=1 sequence=3 RECID=2 STAMP=749667218
input archived log thread=1 sequence=4 RECID=3 STAMP=749667233
input archived log thread=1 sequence=5 RECID=4 STAMP=749667235
input archived log thread=1 sequence=6 RECID=5 STAMP=749667240
input archived log thread=1 sequence=7 RECID=6 STAMP=749667241
input archived log thread=1 sequence=8 RECID=7 STAMP=749667245
input archived log thread=1 sequence=9 RECID=8 STAMP=749667261
input archived log thread=1 sequence=10 RECID=9 STAMP=749667285
input archived log thread=1 sequence=11 RECID=10 STAMP=749667352
input archived log thread=1 sequence=12 RECID=11 STAMP=749667360
input archived log thread=1 sequence=13 RECID=12 STAMP=749667365
channel ORA_DISK_1: starting piece 1 at 28-APR-11
channel ORA_DISK_1: finished piece 1 at 28-APR-11
piece handle=I:\ORA-BACKUP\DB001\BKP_02MAU117_1_1 tag=TAG20110428T165606 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
Finished backup at 28-APR-11


Starting Control File and SPFILE Autobackup at 28-APR-11
piece handle=I:\ORA-BACKUP\DB001\CF_C-1064524120-20110428-00 comment=NONE
Finished Control File and SPFILE Autobackup at 28-APR-11


RMAN>

Most of Oracle DBA's should famiour in windows environment but still we need to follow some process to creating the database instance by using ORADIM and password file creation by using ORAPWD

C:\>SET ORACLE_SID=DB002   --> My Auxiliary guy


C:\>oradim -new -sid DB002 -pfile D:\11g\product\11.2.0\dbhome_1\database\INITdb002.ORA
Instance created.


C:\>orapwd file=D:\11g\product\11.2.0\dbhome_1\database\PWDDB002.ora password=sys entries=10


C:\>




C:\>sqlplus


SQL*Plus: Release 11.2.0.1.0 Production on Thu Apr 28 17:03:40 2011


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


Enter user-name: sys as sysdba
Enter password:
Connected to an idle instance.


SQL> startup nomount
ORACLE instance started.


Total System Global Area  535662592 bytes
Fixed Size                  1375792 bytes
Variable Size             297796048 bytes
Database Buffers          230686720 bytes
Redo Buffers                5804032 bytes
SQL>

My Target & Auxiliary both are in same system but different file structures, so use the below CONVERT parameter in your auxiliary database.

SQL> show parameter convert


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string      G:\oradata\DB001\DB001, G:\oradata\D
                                                 B002
log_file_name_convert                string      G:\oradata\DB001\DB001, G:\oradata\D
                                                 B002


C:\>rman auxiliary sys
Recovery Manager: Release 11.2.0.1.0 - Production on Thu Apr 28 17:41:19 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
auxiliary database Password:
connected to auxiliary database: DB002 (not mounted)


RMAN> DUPLICATE DATABASE TO DB002 BACKUP LOCATION 'I:\Ora-Backup\DB001\';


Starting Duplicate Db at 28-APR-11


contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''DB001'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''DB002'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile from  'I:\ORA-BACKUP\DB001\CF_C-1064524120-20110428-01';
   alter clone database mount;
}
executing Memory Script


sql statement: alter system set  db_name =  ''DB001'' comment= ''Modified by RMAN duplicate'' scope=spfile


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


Oracle instance shut down


Oracle instance started


Total System Global Area     535662592 bytes


Fixed Size                     1375792 bytes
Variable Size                297796048 bytes
Database Buffers             230686720 bytes
Redo Buffers                   5804032 bytes


Starting restore at 28-APR-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK


channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:08
output file name=G:\ORADATA\DB002\CONTROL01.CTL
output file name=G:\ORADATA\DB002\CONTROL02.CTL
Finished restore at 28-APR-11


database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK


contents of Memory Script:
{
   set until scn  13195367;
   set newname for datafile  1 to
 "G:\ORADATA\DB002\SYSTEM01.DBF";
   set newname for datafile  2 to
 "G:\ORADATA\DB002\SYSAUX01.DBF";
   set newname for datafile  3 to
 "G:\ORADATA\DB002\UNDOTBS01.DBF";
   set newname for datafile  4 to
 "G:\ORADATA\DB002\USERS01.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


Starting restore at 28-APR-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 G:\ORADATA\DB002\SYSTEM01.DBF
channel ORA_AUX_DISK_1: restoring datafile 00002 to G:\ORADATA\DB002\SYSAUX01.DBF
channel ORA_AUX_DISK_1: restoring datafile 00003 to G:\ORADATA\DB002\UNDOTBS01.DBF
channel ORA_AUX_DISK_1: restoring datafile 00004 to G:\ORADATA\DB002\USERS01.DBF
channel ORA_AUX_DISK_1: reading from backup piece I:\ORA-BACKUP\DB001\BKP_01MAU0UD_1_1
channel ORA_AUX_DISK_1: piece handle=I:\ORA-BACKUP\DB001\BKP_01MAU0UD_1_1 tag=TAG20110428T165432
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 28-APR-11


contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script


datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=749670210 file name=G:\ORADATA\DB002\SYSTEM01.DBF
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=749670211 file name=G:\ORADATA\DB002\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=749670211 file name=G:\ORADATA\DB002\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=749670211 file name=G:\ORADATA\DB002\USERS01.DBF


contents of Memory Script:
{
   set until scn  13195367;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script


executing command: SET until clause


Starting recover at 28-APR-11
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=11
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=12
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=14
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=15
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=16
channel ORA_AUX_DISK_1: restoring archived log
archived log file name=D:\ARCH\DB002\ARC_DB002_0000000116_0749666459.0001 RECID=103 STAMP=749670751
media recovery complete, elapsed time: 00:02:48
Finished recover at 28-APR-11


contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  db_name =
 ''DB002'' 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     535662592 bytes


Fixed Size                     1375792 bytes
Variable Size                297796048 bytes
Database Buffers             230686720 bytes
Redo Buffers                   5804032 bytes


sql statement: alter system set  db_name =  ''DB002'' 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     535662592 bytes


Fixed Size                     1375792 bytes
Variable Size                297796048 bytes
Database Buffers             230686720 bytes
Redo Buffers                   5804032 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DB002" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( 'G:\ORADATA\DB002\REDO01.LOG' ) SIZE 50 M  REUSE,
  GROUP  2 ( 'G:\ORADATA\DB002\REDO02.LOG' ) SIZE 50 M  REUSE,
  GROUP  3 ( 'G:\ORADATA\DB002\REDO03.LOG' ) SIZE 50 M  REUSE
 DATAFILE
  'G:\ORADATA\DB002\SYSTEM01.DBF'
 CHARACTER SET WE8MSWIN1252




contents of Memory Script:
{
   set newname for tempfile  1 to
 "G:\ORADATA\DB002\TEMP01.DBF";
   switch clone tempfile all;
   catalog clone datafilecopy  "G:\ORADATA\DB002\SYSAUX01.DBF",
 "G:\ORADATA\DB002\UNDOTBS01.DBF",
 "G:\ORADATA\DB002\USERS01.DBF";
   switch clone datafile all;
}
executing Memory Script


executing command: SET NEWNAME


renamed tempfile 1 to G:\ORADATA\DB002\TEMP01.DBF in control file


cataloged datafile copy
datafile copy file name=G:\ORADATA\DB002\SYSAUX01.DBF RECID=1 STAMP=749670954
cataloged datafile copy
datafile copy file name=G:\ORADATA\DB002\UNDOTBS01.DBF RECID=2 STAMP=749670955
cataloged datafile copy
datafile copy file name=G:\ORADATA\DB002\USERS01.DBF RECID=3 STAMP=749670955


datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=749670954 file name=G:\ORADATA\DB002\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=749670955 file name=G:\ORADATA\DB002\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=749670955 file name=G:\ORADATA\DB002\USERS01.DBF


contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script


database opened
Finished Duplicate Db at 28-APR-11


RMAN>

Fell free write your comments here.. Thanks !

Monday, April 25, 2011

Oracle 11g RMAN DUPLICATE DATABASE

Hello Friends, 


Happy New year !!!


This is my first post in 2011 year. [ may it's long time for me]. Now this is the time to share with you guys for Oracle 11g stuff. 


I would like to RMAN Backup / Recovery features in 11g. This will help you all to understand about oracle rman features in 11g { but not like oracle documentation :-) }


RMAN DUPLICATE DATABASE. 


In duplication database here is the three new features.


1. Duplication without a target database connection. Rman obtains metadata about backups from recovery catalog. 


2. Duplication without a target database connection and with out recovery catalog connection. Rman obtains metadata about backup from BACKUP LOCATION.


3. Duplication with a target database connection. Rman obtains metadata about backups from control file / Recovery catalog. 


let me test duplication database without a target database & without recovery catalog.