Вы находитесь на странице: 1из 10

c  

A powerful feature of RMAN is the ability to duplicate (clone), a database from a backup. It is
possible to create a duplicate database on:

`Y A remote server with the same file structure


`Y A remote server with a different file structure
`Y 3he local server with a different file structure

A duplicate database is distinct from a standby database, although both


types of databases are created with the a  command. A
standby database is a copy of the primary database that you can update
continually or periodically by using archived logs from the primary
database. If the primary database is damaged or destroyed, then you can
perform failover to the standby database and effectively transform it into
the new primary database. A duplicate database, on the other hand, cannot
be used in this way: it is not intended for failover scenarios and does not support the various
standby recovery and failover options.

3o prepare for database duplication, you must first create an auxiliary instance. For the
duplication to work, you must connect RMAN to both the target (primary) database and an
auxiliary instance started in NOMOUN3 mode.

So long as RMAN is able to connect to the primary and duplicate instances, the RMAN client
can run on any machine. However, all backups, copies of datafiles, and archived logs used for
creating and recovering the duplicate database must be accessible by the server session on the
duplicate host.

As part of the duplicating operation, RMAN manages the following:

`Y Restores the target datafiles to the duplicate database and performs incomplete
recovery by using all available backups and archived logs.

`Y Shuts down and starts the auxiliary database.

`Y Opens the duplicate database with the RESE3 OGS option after incomplete
recovery to create the online redo logs.

`Y Generates a new, unique DBID for the duplicate database.

 
a  
  
 
a  

½reate an Oracle Password File

First we must create a password file for the duplicate instance.

 
c
a  
     
   

Ensure Oracle Net ½onnectivity to both Instances

Next add the appropriate entries into the 3NSNAMES.ORA and IS3ENER.ORA files in the
$3NS_ADMIN directory.

IS3ENER.ORA

APP1 = 3arget Database, APP2 = Auxiliary Database

IS3ENER =
(DES½RIP3ION_ IS3 =
(DES½RIP3ION =
(ADDRESS = (PRO3O½O = 3½P)(HOS3 = gentic)(POR3 = 1521))
)
)

SID_ IS3_ IS3ENER =


(SID_ IS3 =
(SID_DES½ =
(G OBA _DBNAME = APP1.WOR D)
(ORA½ E_HOME = /opt/oracle/product/10.2.0)
 a
 
)
(SID_DES½ =
(G OBA _DBNAME = APP2.WOR D)
(ORA½ E_HOME = /opt/oracle/product/10.2.0)
 a
  
)
)

3NSNAMES.ORA

APP1 = 3arget Database, APP2 = Auxiliary Database

ca =
(DES½RIP3ION =
(ADDRESS_ IS3 =
(ADDRESS = (PRO3O½O = 3½P)(HOS3 = gentic)(POR3 = 1521))
)
(½ONNE½3_DA3A =
(SERVI½E_NAME = APP1.WOR D)
)
)

 ca =
(DES½RIP3ION =
(ADDRESS_ IS3 =
(ADDRESS = (PRO3O½O = 3½P)(HOS3 = gentic)(POR3 = 1521))
)
(½ONNE½3_DA3A =
(SERVI½E_NAME = APP2.WOR D)
)
)

SQ NE3.ORA

NAMES.DIRE½3ORY_PA3H= (3NSNAMES)
NAMES.DEFAU 3_DOMAIN = WOR D
NAME.DEFAU 3_ZONE = WOR D
USE_DEDI½A3ED_SERVER = ON

Now restart the istener








½reate an Initialization Parameter File for the Auxiliary Instance

½reate an INI3.ORA parameter file for the auxiliary instance, you can copy that from the target
instance and then modify the parameters.

### Duplicate Database


### -----------------------------------------------
# 3his is only used when you duplicate the database
# on the same host to avoid name conflicts

a


c    
c


c    

 
  

### Global database name is db_name.db_domain


### -----------------------------------------

db_name = APP2
db_unique_name = APP2_GEN3I½
db_domain = WOR D
service_names = APP2
instance_name = APP2

### Basic ½onfiguration Parameters


### ------------------------------

compatible = 10.2.0.4
db_block_size = 8192
db_file_multiblock_read_count = 32
db_files = 512
control_files = /u01/oracle/db/APP2/con/APP2_con01.con,
/opt/oracle/db/APP2/con/APP2_con02.con

### Database Buffer ½ache, I/O


### --------------------------
# 3he Parameter SGA_3ARGE3 enables Automatic Shared Memory Management

sga_target = 500M
sga_max_size = 600M

### REDO ogging without Data Guard


### -------------------------------

log_archive_format = APP2_%s_%t_%r.arc
log_archive_max_processes =2
log_archive_dest = /u01/oracle/db/APP2/arc

### System Managed Undo


### -------------------

undo_management = auto
undo_retention = 10800
undo_tablespace = undo

### 3races, Dumps and Passwordfile


### ------------------------------

audit_file_dest = /u01/oracle/db/APP2/adm/admp
user_dump_dest = /u01/oracle/db/APP2/adm/udmp
background_dump_dest = /u01/oracle/db/APP2/adm/bdmp
core_dump_dest = /u01/oracle/db/APP2/adm/cdmp
utl_file_dir = /u01/oracle/db/APP2/adm/utld
remote_login_passwordfile = exclusive

½reate a full Database Backup


Make sure that a full backup of the target is accessible on the duplicate host. You can use the
following BASH script to backup the target database.

rman nocatalog target / <<-EOF


configure retention policy to recovery window of 3 days;
configure backup optimization on;
configure controlfile autobackup on;
configure default device type to disk;
configure device type disk parallelism 1 backup type to compressed backupset;
configure datafile backup copies for device type disk to 1;
configure maxsetsize to unlimited;
configure snapshot controlfile name to '/u01/backup/snapshot_controlfile';
show all;

run {
allocate channel ch1 type Disk maxpiecesize = 1900M;
backup full database noexclude
include current controlfile
format '/u01/backup/datafile_%s_%p.bak'
tag 'datafile_daily';
}

run {
allocate channel ch1 type Disk maxpiecesize = 1900M;
backup archivelog all
delete all input
format '/u01/backup/archivelog_%s_%p.bak'
tag 'archivelog_daily';
}

run {
allocate channel ch1 type Disk maxpiecesize = 1900M;
backup format '/u01/backup/controlfile_%s.bak' current controlfile;
}

crosscheck backup;
list backup of database;
report unrecoverable;
report schema;
report need backup;
report obsolete;
delete noprompt expired backup of database;
delete noprompt expired backup of controlfile;
delete noprompt expired backup of archivelog all;
delete noprompt obsolete recovery window of 3 days;
quit
EOF


 a  
a

  


Before beginning RMAN duplication, use SQ Plus to connect to the auxiliary instance and
start it in NOMOUN3 mode. If you do not have a server-side initialization parameter file for the
auxiliary instance in the default location, then you must specify the client-side initialization
parameter file with the PFI E parameter on the DUP I½A3E command.

Get original Filenames from 3ARGE3

3o rename the database files you can use the SE3 NEWNAME command. 3herefore, get the
original filenames from the target and modify these names in the DUP I½A3E command.

c
a 
 
c
a

set feed off


set pagesize 10000
column name format a40 heading "Datafile"
column file# format 99 heading "File-ID"

select name, file# from v$dbfile;

column member format a40 heading " ogfile"


column group# format 99 heading "Group-Nr"

select member, group# from v$logfile;

Datafile File-ID
---------------------------------------- -------
/u01/oracle/db/APP1/sys/APP1_sys1.dbf 1
/u01/oracle/db/APP1/sys/APP1_undo1.dbf 2
/u01/oracle/db/APP1/sys/APP1_sysaux1.dbf 3
/u01/oracle/db/APP1/usr/APP1_users1.dbf 4

ogfile Group-Nr
---------------------------------------- --------
/u01/oracle/db/APP1/rdo/APP1_log1A.rdo 1
/opt/oracle/db/APP1/rdo/APP1_log1B.rdo 1
/u01/oracle/db/APP1/rdo/APP1_log2A.rdo 2
/opt/oracle/db/APP1/rdo/APP1_log2B.rdo 2
/u01/oracle/db/APP1/rdo/APP1_log3A.rdo 3
/opt/oracle/db/APP1/rdo/APP1_log3B.rdo 3
/u01/oracle/db/APP1/rdo/APP1_log4A.rdo 4
/opt/oracle/db/APP1/rdo/APP1_log4B.rdo 4
/u01/oracle/db/APP1/rdo/APP1_log5A.rdo 5
/opt/oracle/db/APP1/rdo/APP1_log5B.rdo 5
/u01/oracle/db/APP1/rdo/APP1_log6A.rdo 6
/opt/oracle/db/APP1/rdo/APP1_log6B.rdo 6
/u01/oracle/db/APP1/rdo/APP1_log7A.rdo 7
/opt/oracle/db/APP1/rdo/APP1_log7B.rdo 7
/u01/oracle/db/APP1/rdo/APP1_log8A.rdo 8
/opt/oracle/db/APP1/rdo/APP1_log8B.rdo 8
/u01/oracle/db/APP1/rdo/APP1_log9A.rdo 9
/opt/oracle/db/APP1/rdo/APP1_log9B.rdo 9
/u01/oracle/db/APP1/rdo/APP1_log10A.rdo 10
/opt/oracle/db/APP1/rdo/APP1_log10B.rdo 10

½reate Directories for the duplicate Database

  

  

  
 
  
  
 

 



   
c 

Oracle must be able to locate the Password and INI3.ORA File.


c
c
       
     
 
 

a  

a


Now you are ready to duplicate the database APP1 to APP2.

c
a  
 
c
a

   


 
       
 
 


   

Recovery Manager: Release 10.2.0.4.0 - Production on 3ue Oct 28 12:00:13 2008


½opyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: APP1 (DBID=3191823649)
connected to auxiliary database: APP2 (not mounted)

 

 cac  

 ca c  

 ca!c  
 
 ca"c  

a a c 
      
 
c
cc   
 

  
   
c    
 

  
   
c !  
 !

  
 !  
c "  
 "

  
 "  
c   
 

  
   
c #  
 #

  
 #  
c $  
 $

  
 $  
c %  
 %

  
 %  
c &  
 &

  
 &  
c   
 

  
   
'

3he whole, long output is not shown here, but check, that RMAN was able to open the duplicate
database with the RESE3 OGS option.

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

database opened
Finished Duplicate Db at 28-O½3-08

As the final step, eliminate or uncomment the a 


  and


  in the INI3.ORA file and restart the database.

initAPP2.ora

### Duplicate Database


### -----------------------------------------------
# 3his is only used when you duplicate the database
# on the same host to avoid name conflicts
# DB_FI E_NAME_½ONVER3 = (/u01/oracle/db/APP1/,/u01/oracle/db/APP2/)
# OG_FI E_NAME_½ONVER3 = (/u01/oracle/db/APP1/,/u01/oracle/db/APP2/,
/opt/oracle/db/APP1/,/opt/oracle/db/APP2/)

  
 






3otal System Global Area 629145600 bytes


Fixed Size 1269064 bytes
Variable Size 251658936 bytes
Database Buffers 373293056 bytes
Redo Buffers 2924544 bytes
Database mounted.
Database opened.

 a  
a





3his scenario is exactly the same as described for the local host. ½opy the RMAN Backup files
to the remote host on the same directory as on the localhost.

 
  
 ( )

3he other steps are the same as described under «½reating a Duplicate Database on the ocal
Host».

Вам также может понравиться