Oracle10G RMAN Database Duplication (Doc ID 259694.1)

rongshiyuan發表於2013-12-12
Oracle10G RMAN Database Duplication (Doc ID 259694.1)

***Checked for relevance on 29-Mar-2012***

[ Creating a duplicate database using RMAN ]

The V10gREL5 is in noarchivelog mode. The duplication is being made from
closed database consistent backups. With archivelog mode databases you can
use the "set until time | scn | sequence" clause to tell RMAN where to end
for incomplete recovery.

TARGET : V10gREL5 
AUXILIARY : RMAN10   

[ SQLNET setup for connectivity ]
########################################################################################
# We must use a dedicated listener configuration for RMAN. Using instance registration
# requires the database be mounted to register with the listener. Since the AUX is
# where we'll connect using sqlnet we require sysdba access to the nomount instance.
# This example is using the same server for duplication but can be used for remote
# duplication as well. If you are using a disk backup solution and duplicate to a
# remote node you must first copy the backupsets from the original hosts backup
# location to the same mount and path on the remote server. Because duplication
# uses auxiliary channels the files must be where the IO pipe is allocated. So the
# IO will take place on the remote node and disk backups must be locally available.
#########################################################################################

Listener.ora:
=============

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = stsmesun1)(PORT = 1521))
      )
    )
  )


SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /database/10i/app/oracle/product/10g_Prod_REL5)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = V10gREL5)
      (ORACLE_HOME = /database/10i/app/oracle/product/10g_Prod_REL5)
      (SID_NAME = V10gREL5)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = RMAN10)
      (ORACLE_HOME = /database/10i/app/oracle/product/10g_Prod_REL5)
      (SID_NAME = RMAN10)
    )
  )

tnsnames.ora:
=============

RMAN10 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = stsmesun1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = RMAN10)
    )
  )

V10R5 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = stsmesun1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = V10gREL5)
    )
  )


# Target Database Files:

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/database/10i/app/oracle/oradata/V10gREL5/system01.dbf
/database/10i/app/oracle/oradata/V10gREL5/undotbs01.dbf
/database/10i/app/oracle/oradata/V10gREL5/sysaux01.dbf
/database/10i/app/oracle/oradata/V10gREL5/users01.dbf


  [ Create the Auxiliary Database directories needed ]

% cd $ORACLE_HOME/dbs

# Note: I am using a single directory for my datafiles. You can use the
# parameters db_file_name_convert and log_file_name_convert and they will
# generate the "set newname for datafile" syntax needed to change the
# controlfile. These parameters accommodate up to 5 different file placement
# locations using:

db_file_name_convert = ('/old/path1', '/new/path1',
                        '/old/path2', '/new/path2',
                        '/old/path3', '/new/path3')
# up to 5 locations from Oracle9i >.
log_file_name_convert = ('/old/path1', '/new/path1',
                         '/old/path2', '/new/path2',
                         '/old/path3', '/new/path3')
# up to 5 locations from Oracle9i >.

# You can also create your own "set newname for datafile" syntax for all your
# files skipping these parameters all together. You can still use the
# log_file_name_convert parameter or you can use the 'logfile' command to
# specifiy where the logs will be created and what size.
#
# Auxiliary datafile directory for this exercise:

"/database/10i/marrocha/RMAN10/oradata"

  [ Create the Auxiliary init.ora ]

# the controlfile is created during duplication with the path and name given here
#
# initRMAN10.ora

db_name = RMAN10
db_block_size = 8192
compatible = 10.1.0.1.0
remote_login_passwordfile = exclusive
control_files = ('/database/10i/marrocha/RMAN10/oradata/control01.ctl',
                 '/database/10i/marrocha/RMAN10/oradata/control02.ctl')
db_file_name_convert = ('/database/10i/app/oracle/oradata/V10gREL5',
                        '/database/10i/marrocha/RMAN10/oradata')
log_file_name_convert = ('/database/10i/app/oracle/oradata/V10gREL5',
                         '/database/10i/marrocha/RMAN10/oradata')


# create a passwordfile for remote connections as sysdba

% orapwd password= file=orapwRMAN10

% sqlplus /nolog
SQL> connect / as sysdba
SQL> startup nomount pfile=$ORACLE_HOME/dbs/initRMAN10.ora
SQL> exit


[ RMAN Duplication from tape backup using the Oracle disk API ]

# This is to provide an example of simulating writing to tape using RMAN and
# the Oracle disk API. RMAN Target Configuration:

% rman
RMAN> connect target

connected to target database: V10GREL5 (DBID=2510891965)

# Use the RMAN configure command to create an optimal configuration for your
# business. the channels are configured to allocate from device type SBT by
# default. Since the channels are configured here we do not need to allocate
# any channels in the RMAN scripts.
# I/O only take place over the channel allocated. If an AUX channel is allocated
# only the auxiliary will perform IO so there is not worry about overwriting the
# target database production files. As an added safegard an error would raise if
# an attempt to overwrite a target file while it's online.

RMAN> show all;

using target database controlfile instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'SBT_TAPE' TO 'V10GREL5_%F';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS  'SBT_LIBRARY=oracle.disksbt,
                                                 ENV=(BACKUP_DIR=/backup/rman/tape)';
CONFIGURE MAXSETSIZE TO UNLIMITED;
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/backup/rman/snapcf_V10gREL5.f';
RMAN> exit


[ Start the Duplication ]

# set the env to the auxiliary to "startup nomount"

setenv ORACLE_SID RMAN10 # csh
or
ORACLE_SID=RMAN10 export ORACLE_SID # ksh

% sqlplus /nolog
SQL> connect / as sysdba
     Connected to an idle instance
SQL> startup nomount pfile=$ORACLE_HOME/dbs/initRMAN10.ora
SQL> exit

# Set your SID back to the TARGET for duplication. The information in the target
# is used by the duplicate to fill in missing information like maxopenfiles,
# maxlogfiles and other values which are only changed when recreating the control
# file. Execute RMAN from the target home. The auxiliary should be a sqlnet
# connection.

[stsmesun1]/home/beta/marrocha> rman trace dup_rman10.log

Recovery Manager: Release 10.1.0.2.0 - Production

Copyright (c) 1995, 2003, Oracle.  All rights reserved.

RMAN> connect target

connected to target database: V10GREL5 (DBID=2510891965)

RMAN> connect auxiliary sys/rman10@RMAN10

connected to auxiliary database: RMAN10 (not mounted)

RMAN> duplicate target database to RMAN10 device type sbt;

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

database opened
Finished Duplicate Db at 09-DEC-03

>>>EOF<<<

To complete the process remove or comment out the db and log convert parameters.
Restart the database. Your duplicate database is ready for use.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17252115/viewspace-1063120/,如需轉載,請註明出處,否則將追究法律責任。

相關文章