Friday, April 20, 2012

Clone database from a RMAN Cold back in Oracle 10g


Clone database from a RMAN Cold back in Oracle 10g


Database environment:
·         Oracle version: 10.2.0.4se
·         RMAN version: 10.2.0.4
·         OS: Solaris 10
·         Target database: TargetDB
·         Auxiliary database: AuxDB
·         RMAN catalog database: RcatDB

1. Take a cold backup from the target database TargetDB (source database) and using RMAN catalog database RcatDB

2. Prepare the directory structure for the auxiliary database AuxDB (cloned database)

Scenario:
·         The target database and the auxiliary database are on different database servers.
·         Need to copy the cold backups of the target database from one server to the server where the auxiliary database resides.
·         The file structure of the cold  backup should be the same as on the target database server.

3. Ensure the following two parameters are included in the pfile:

############################################
# for rman database duplication
###########################################

db_file_name_convert=('/oracle_data/TargetDB', '/oracle_data/AuxDB')
log_file_name_convert=('/oracle_data/TargetDB', '/oracle_data/AuxDB')

4. Add the auxiliary database to /etc/oratab:

AuxDB:/fs/u02/sw_ux/oracle/product/10.2.0.4se:Y

5. Add the auxiliary database to tnsnames.ora

AuxDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = host_name)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = AuxDB)
      (SERVER = DEDICATED)
    )
  )

6. Add a Oracle password file for the auxiliary database

orapwd file=$ORACLE_HOME/dbs/orapwAuxDB password= entries=10

7. Start the auxiliary database in NOMOUNT mode

$ . oraenv
ORACLE_SID = [AuxDB] ? AuxDB
The /oracle/product/10.2.0.4se/bin/orabase binary does not exist
You can set ORACLE_BASE manually if it is required.

$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Oct 25 11:26:32 2010
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
Connected to an idle instance.

SQL> create spfile from pfile='/oracle/admin/AuxDB/pfile/initAuxDB.ora';
File created.

SQL> startup nomount
ORACLE instance started.

Total System Global Area  683671552 bytes
Fixed Size                  2043136 bytes
Variable Size             276828928 bytes
Database Buffers          398458880 bytes
Redo Buffers                6340608 bytes
8. Use RMAN to clone the auxiliary database

$ rman trace clone_AuxDB.log

Recovery Manager: Release 10.2.0.4.0 - Production on Mon Oct 25 11:44:53 2010

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

RMAN> connect target sys/syspwd@TargetDB;

connected to target database: TargetDB (DBID=1722637034)

RMAN>  connect catalog rman/rcpwd@RcatDB;

connected to recovery catalog database

RMAN> connect auxiliary /

connected to auxiliary database: AuxDB (not mounted)

RMAN> duplicate target database to AuxDB;

Finished restore at 25-OCT-10

sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUXDB" RESETLOGS NOARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      2
  MAXDATAFILES       30
  MAXINSTANCES     1
  MAXLOGHISTORY     2337
 LOGFILE
  GROUP 1 ( '/oracle_data/AuxDB/redo01.log', '/oracle_data/AuxDB/redo01b.log' ) SIZE 10 M  REUSE,
  GROUP 2 ( '/oracle_data/AuxDB/redo02.log', '/oracle_data/AuxDB/redo02b.log' ) SIZE 10 M  REUSE,
  GROUP 3 ( '/oracle_data/AuxDB/redo03.log', '/oracle_data/AuxDB/redo03b.log' ) SIZE 10 M  REUSE
 DATAFILE
  '/oracle_data/AuxDB/system_01.dbf'
 CHARACTER SET UTF8


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

released channel: ORA_AUX_DISK_1
datafile 3 switched to datafile copy
input datafile copy recid=1 stamp=733319493 filename=/oracle_data/AuxDB/sysaux_01.dbf
datafile 12 switched to datafile copy
input datafile copy recid=10 stamp=733319493 filename=/oracle_data/AuxDB/users01.dbf
datafile 13 switched to datafile copy
input datafile copy recid=11 stamp=733319493 filename=/oracle_data/AuxDB/undotbs01.dbf

contents of Memory Script:
{
   recover
   clone database
   noredo
   ,
    delete archivelog
   ;
}
executing Memory Script

Starting recover at 25-OCT-10
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=104 devtype=DISK
Finished recover at 25-OCT-10

contents of Memory Script:
{
   shutdown clone;
   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     683671552 bytes

Fixed Size                     2043136 bytes
Variable Size                276828928 bytes
Database Buffers             398458880 bytes
Redo Buffers                   6340608 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUXDB" RESETLOGS NOARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      2
  MAXDATAFILES       30
  MAXINSTANCES     1
  MAXLOGHISTORY     2337
 LOGFILE
  GROUP  1 ( '/oracle_data/AuxDB/redo01.log', '/oracle_data/AuxDB/redo01b.log' ) SIZE 10 M  REUSE,
  GROUP  2 ( '/oracle_data/AuxDB/redo02.log', '/oracle_data/AuxDB/redo02b.log' ) SIZE 10 M  REUSE,
  GROUP  3 ( '/oracle_data/AuxDB/redo03.log', '/oracle_data/AuxDB/redo03b.log' ) SIZE 10 M  REUSE
 DATAFILE
  '/oracle_data/AuxDB/system_01.dbf'
 CHARACTER SET UTF8

contents of Memory Script:
{
   set newname for tempfile  1 to
 "/oracle_data/AuxDB/temp_01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "/oracle_data/AuxDB/sysaux_01.dbf";
   catalog clone datafilecopy  "/oracle_data/AuxDB/data_01.dbf";
   catalog clone datafilecopy  "/oracle_data/AuxDB/indexes_01.dbf";
   catalog clone datafilecopy  "/oracle_data/AuxDB/users01.dbf";
   catalog clone datafilecopy  "/oracle_data/AuxDB/undotbs01.dbf";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed temporary file 1 to /oracle_data/AuxDB/temp_01.dbf in control file

cataloged datafile copy
datafile copy filename=/oracle_data/AuxDB/sysaux_01.dbf recid=1 stamp=733319503


cataloged datafile copy
datafile copy filename=/oracle_data/AuxDB/undotbs01.dbf recid=11 stamp=733319503

datafile 3 switched to datafile copy
input datafile copy recid=1 stamp=733319503 filename=/oracle_data/AuxDB/sysaux_01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=2 stamp=733319503 filename=/oracle_data/AuxDB/data_01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=5 stamp=733319503 filename=/oracle_data/AuxDB/indexes_01.dbf
datafile 8 switched to datafile copy
input datafile copy recid=10 stamp=733319503 filename=/oracle_data/AuxDB/users01.dbf
datafile 13 switched to datafile copy
input datafile copy recid=11 stamp=733319503 filename=/oracle_data/AuxDB/undotbs01.dbf

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

database opened
Finished Duplicate Db at 25-OCT-10

RMAN>

RMAN> exit


Recovery Manager complete.
9. Complete.

No comments:

Post a Comment