Saturday, March 30, 2013

Duplicating database to a new Host without connecting to the Target database:


To Take backup :

rman target =/                           
  
CONFIGURE CONTROLFILE AUTOBACKUP ON;
run {
set controlfile autobackup format for device type disk to '/nfs/rman_db_backup/PROD/%F';
shutdown immediate
startup mount
allocate channel t1 device type disk;
allocate channel t2 device type disk;
backup as compressed backupset database format '/nfs/rman_db_backup/PROD/%d_%s_%p.dbf';
backup current controlfile format '/nfs/rman_db_backup/PROD/ctrl%d_%s_%p.ctl';
release channel t1;
release channel t2;
}

Scenario 1:

rman msglog=duplicatePROD2UAT.log << END_RMAN
connect target sys/P6d_9@PROD
connect auxiliary /
connect catalog rmn_cat/cat4rman@grid

RUN
{
ALLOCATE AUXILIARY CHANNEL disk1 DEVICE TYPE disk;
ALLOCATE AUXILIARY CHANNEL disk2 DEVICE TYPE disk;
ALLOCATE AUXILIARY CHANNEL disk3 DEVICE TYPE disk;
ALLOCATE AUXILIARY CHANNEL disk4 DEVICE TYPE disk;
ALLOCATE AUXILIARY CHANNEL disk5 DEVICE TYPE disk;
ALLOCATE AUXILIARY CHANNEL disk6 DEVICE TYPE disk;

   set newname for datafile  1 to '/u01/oradata/UAT/system01.dbf';
   set newname for datafile  2 to '/u01/oradata/UAT/system02.dbf';
   set newname for datafile  3 to '/u01/oradata/UAT/taxware01.dbf';
   set newname for datafile  4 to '/u02/oradata/UAT/undo01.dbf';
   set newname for datafile  5 to '/u02/oradata/UAT/undo02.dbf';
   set newname for datafile  6 to '/u02/oradata/UAT/discoverer01.dbf';
   set newname for datafile  7 to '/u01/oradata/UAT/discoverer02.dbf';
   set newname for datafile  8 to '/u02/oradata/UAT/olap.dbf';
   set newname for datafile  9 to '/u02/oradata/UAT/olap.dbf';
   set newname for datafile  10 to '/u02/oradata/UAT/sysaux01.dbf';

set until time "to_date('11-DEC-2010 21:17:00','DD-MON-YYYY HH24:MI:SS')";

DUPLICATE TARGET DATABASE TO UAT NOFILENAMECHECK ;

RELEASE CHANNEL disk1;
RELEASE CHANNEL disk2;
RELEASE CHANNEL disk3;
RELEASE CHANNEL disk4;
RELEASE CHANNEL disk5;
RELEASE CHANNEL disk6;
}
exit
END_RMAN
exit

++++++++++++++++++++++++++++++++++++++++++++

Scenario 2:

rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Oct 15 06:49:58 2012

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

connected to target database (not started)

RMAN> set dbid=6186969

executing command: SET DBID

RMAN> exit
Recovery Manager complete.

### Backup pieces  location

[oracle@uatebsdl1 ~]$ cd /nfs/rman_db_backup/PROD 
[oracle@uatebsdl1 PROD]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Mon Oct 15 06:57:06 2012

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

Connected to an idle instance.

SQL> startup nomount pfile='/d02/oracle/uatdb/11.2.0.3/dbs

ORA-01506: missing or illegal database name

[oracle@uatebsdl1 PROD]$ export ORACLE_SID=PROD
[oracle@uatebsdl1 PROD]$ export ORACLE_HOME=/d02/oracle/uatdb/11.2.0.3
[oracle@uatebsdl1 PROD]$  sqlplus / as sysdba

SQL>  startup nomount pfile='/d02/oracle/uatdb/11.2.0.3/dbs/initPROD.ora'
QL*Plus: Release 11.2.0.3.0 Production on Mon Oct 15 06:59:00 2012

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

Connected to an idle instance.

ORACLE instance started.

Total System Global Area 5.3447E+10 bytes
Fixed Size                  2240984 bytes
Variable Size            7113543208 bytes
Database Buffers         4.6305E+10 bytes
Redo Buffers               26505216 bytes
SQL> exit
## To verify it will connect the Target database

[oracle@uatebsdl1 PROD]$ rman target /  

Recovery Manager: Release 11.2.0.3.0 - Production on Mon Oct 15 07:08:01 2012

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

connected to target database: PROD (not mounted) 

## Restore Control files from backup pieces..

RMAN> restore controlfile from '/nfs/rman_db_backup/PROD/CF_c-361538929-20121013-03_PROD_20121013.bak';

Starting restore at 15-OCT-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=6674 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
output file name=/u03/oradata/UAT/cntrl01.dbf
output file name=/u03/oradata/UQAT/cntrl02.dbf
output file name=/u03/oradata/UAT/cntrl03.dbf
Finished restore at 15-OCT-12

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

## Apply the Backup pieces one by one ...

RMAN> catalog backuppiece '/nfs/rman_db_backup/PROD/DF_796595692_a4nnm5fc_16708_1_TX_DATA_PROD_20121013.bak';

cataloged backup piece
backup piece handle=/nfs/rman_db_backup/PROD/DF_796595692_a4nnm5fc_16708_1_TX_DATA_PROD_20121013.bak RECID=14888 STAMP=796721805

RMAN> catalog backuppiece '/nfs/rman_db_backup/PROD/DF_796596589_a9nnm6bd_16713_1_OWAPUB_PROD_20121013.bak';

cataloged backup piece
backup piece handle=/nfs/rman_db_backup/PROD/DF_796596589_a9nnm6bd_16713_1_OLAP_PROD_20121013.bak RECID=14889 STAMP=796721920

...........
.........

RMAN>
run
{
Set newname for datafile '/u03/oradata/PROD/sysaux01.dbf' to '/u03/oradata/UAT/sysaux01.dbf';
Set newname for datafile '/u03/oradata/PROD/system02.dbf' to '/u03/oradata/UAT/system02.dbf';
Set newname for datafile '/u03/oradata/PROD/system01.dbf' to '/u03/oradata/UAT/system01.dbf';
Set newname for datafile '/u03/oradata/PROD/taxware01.dbf' to '/u03/oradata/UAT/taxware01.dbf';
Set newname for datafile '/u03/oradata/PROD/undo02.dbf' to '/u03/oradata/UAT/undo02.dbf';
Set newname for datafile '/u03/oradata/PROD/undo01.dbf'' to '/u03/oradata/UAT/undo01.dbf';
Set newname for datafile '/u03/oradata/PROD/olap.dbf' to '/u03/oradata/UAT/olap.dbf';
Set newname for datafile '/u03/oradata/PROD/user01.dbf' to '/u03/oradata/UAT/user01.dbf';
Set newname for datafile '/u03/oradata/PROD/TX_DATA01.dbf' to '/u03/oradata/UAT/TX_DATA01.dbf';
Set newname for datafile '/u03/oradata/PROD/TX_DATA2.dbf' to '/u03/oradata/UAT/TX_DATA2.dbf';
restore database;
switch datafile all;
recover database;
}

++++++++++++++++++++++++++++++++++++++++++++++
orauat> rman target =/          

Recovery Manager: Release 11.2.0.2.0 - Production on Fri Mar 8 23:19:18 2013

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

connected to target database: PBW (DBID=164864990, not open)

RMAN> recover database ;

RMAN-00571: ===========================================
RMAN-00569: ===== ERROR MESSAGE STACK FOLLOWS =======
RMAN-00571: ============================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "archivelog, channel, check, controlfile, database, datafile, device, force, from, high, preview, primary,
skip readonly, spfile, standby, tablespace, to restore point, until restore point, until, validate, ("
RMAN-01008: the bad identifirecover
RMAN-01007: at line 1 column 9 file: standard input

RMAN> list backup of archivelog sequence 120662;

using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
7       61.93G     DISK        00:00:00     06-MAR-13
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: PBWARCB06MAR2013
        Piece Name: /oraclebackupb/backupset/Lvl0_backup_9eo3ruu7_1_1.arc

  List of Archived Logs in backup set 7
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    120662 36239220127 06-MAR-13 36239467349 06-MAR-13

RMAN> list backup of archivelog sequence 120661;
List of Backup Sets
===================
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
7       61.93G     DISK        00:00:00     06-MAR-13
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: PBWARCB06MAR2013
        Piece Name: /oraclebackupb/backupset/Lvl0_backup_9eo3ruu7_1_1.arc

  List of Archived Logs in backup set 7
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    120661 36240111295 06-MAR-13 36240301600 06-MAR-13

RMAN> run
2> {
3> set until sequence 120662;
4> recover database;
5> }

executing command: SET until clause

Starting recover at 08-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=6 device type=DISK

starting media recovery

 +++++++++++++++++++++++++++++++++++++++

No comments:

Post a Comment