Database duplicates/clones

This chapter presents the database creation script dbdupli.ksh.

Prerequisites

In the current release of DMK_DBDUPLICATE the following prerequisites apply:

  • It is recommended to start dbdupli.ksh on the host where the cloned/duplicated database will run

  • When the duplicated database shall resize on the same host then the "db_unique_name" parameter must be set in the spfile for the auxiliary instance

  • On the auxiliary host the following must be present:

    • Oracle Binaries must be already installed

    • An Oracle Listener must be up and running with a static entry for the database to be cloned to

    • The password file for the database to be cloned to must be prepared with same sys password as on the database to clone from

    • The spfile for the database to be cloned to must be already in place

      • Take care of the convert parameters

    • The directory structure for the following must be already there

      • adump

      • All the directories for the data files if not on ASM

      • The directory for the fast recovery area when not on ASM

      • The ADMIN directory structure

    • Windows only: The Oracle service must be created (oradim)

⚠️Connections to the databases to be cloned to as sysdba must be working from each host

Command-line parameters

The execution of dbdupli.ksh requires a configuration file, which contains the following parameters.

The script requires command lines argument in addition to the configuration file. Some of the configuration file parameters are also available in command-line.

The parameters given in command line are from higher priority compared to their configuration values.

–f <configuration file>

This parameter is mandatory as it points to the configuration file for the duplicate, e.g.:

${DMK_DBDUPLICATE/etc/refresh_TEST.cfg

An example configuration file can be found in the templates directory of DMK_DBDUPLICATE :

${DMK_DBDUPLICATE/templates/refresh_TEMPLATE.cfg

Point-In-Time recovery

–d <The date to clone from >

Optional parameter which specifies the date the clone shall be created from. This option is only available using duplication from backup and can only be executed through command lines.

Format of the date to be used is DDMMYYYY.

–t <The time of the day to clone from>

Optional parameter which specifies the time of the day the clone shall be created from. In case only rdate is specified and rtime is not specified, 00:00:00 will be used as default time. This option is only available using duplication from backup and can only be executed through command lines.

Format of the time to be used is HHMISS.

Example for a Point-In-Time recovery dated from June the 3rd 2020 at 15:38:00 :

oracle@vmdmkdbboradg1:/u01/app/oracle/ [DB1] dbdupli.ksh -f /u01/app/oracle/local/dmk_dbduplicate/etc/refresh_DB1.cfg -d 03062020 -t 153800

⚠️Point-In-Time recovery will be ignored in case a duplication for standby is selected.

–s or –standby

Optional parameter which specifies a standby database duplication. This option is only available through command lines. It can be used either from active or from backup. Parameter must be followed with YES.

Example :

oracle@vmdmkdbboradg1:/u01/app/oracle/ [DB1] dbdupli.ksh -f
/u01/app/oracle/local/dmk_dbduplicate/etc/refresh_DB1.cfg -standby YES

OR

oracle@vmdmkdbboradg1:/u01/app/oracle/ [DB1] dbdupli.ksh -f
/u01/app/oracle/local/dmk_dbduplicate/etc/refresh_DB1.cfg -s YES

–r <NO_DROP, DROP or SILENT_DROP>

Optional parameter to clean up the TSID Database.

DROP : Interactive deletion, a confirmation will be required

SILENT_DROP : Silent deletion, no confirmation will be required

NO_DROP : No database deletion will happened. Default parameter

Configuration file parameters

SSID

#*************************************************************
# the SID of the source database (the database to clone from)
# Default : can't be null
SSID=PROD

TSID

#*************************************************************
# the SID of the target/auxiliary database (the database to clone to)
# Default : can't be null
TSID=TEST

SSID_CONNECT

#*************************************************************
# database connect string to clone from
# Default : can't be null
SSID_CONNECT=sys/sys@PROD

TSID_CONNECT

#*************************************************************
# database connect string to clone to
# Default : can't be null
TSID_CONNECT=sys/sys@TEST

RMAN_CATALOG_CONNECT

#*************************************************************
# Connect string to the rman catalog, if any
# Default is : "null" (nocatalog)
RMAN_CATALOG_CONNECT=""

CLONE_MODE

#*************************************************************
# CLONE_MODE mode can be either ACTIVE or BACKUP
# Default is : "BACKUP"
Clone_Mode=BACKUP

BACKUP_LOCATION

#*************************************************************
# the backup location for duplicates from backup
# this must be accessible from the host where
# the auxiliary instance is hosted
Backup_Location=/u90/backup/TEST/

BACKUP_TYPE

#*************************************************************
# the type of backup which is used for backing up the databases
# Type of channel to allocate
# Valid types are "disk" or "sbt_tape"
# Default is : "disk"
Backup_Type=DISK

SBT_TAPE_PARMS

The parameters used when cloning from tape for accessing the media manager integration.

# when the backup_type is tape we need to know the sbt
# parameters
SBT_TAPE_PARMS='SBT_LIBRARY=oracle.disksbt
ENV=(BACKUP_DIR=/u90/backup/DB122/)'

NOFILENAMECHECK

Prevents RMAN from checking whether the data files and online redo logs files of the source database are in use when the source database files share the same names as the duplicate database files. You are responsible for determining that the duplicate operation does not overwrite useful data.

This option is necessary when you are creating a duplicate database in a different host that has the same disk configuration, directory structure, and file names as the host of the source database.

The value of this parameter can be either "YES" or "NO". Everything else is ignored and NOFILENAMECHECK will not be included in the duplicate command.

#*************************************************************
# specifiy the nofilenamecheck parameter for the duplicate
# The value of this parameter can be either YES or NO
# Default is : "No"
NoFileNameCheck=Yes

POSTSCRIPT

A script to be executed one the duplicate finished can be specified here. This is e.g. useful if the cloned database shall be taken out of archive mode once duplication completed.

The script provided does not need to provide connect information as this is done automatically. Connection to the auxiliary database is performed as sysdba.

#*************************************************************
# a post SQL*Plus script to run on the auxiliary database
# after the duplicate completed
# this can e.g. be useful for disabling archive log
# once the duplicate completed
# Default is : null
Post_Script=""

TSID_DATABASE_CLEANUP

The parameter to use to be able to cleanup the TSID database.

DROP : Interactive deletion, a confirmation will be required

SILENT_DROP : Silent deletion, no confirmation will be required

NO_DROP : No database deletion will happened. Default parameter

# Clean the target/auxiliary database (the database to clone to)
# Value NO_DROP, DROP or SILENT_DROP
TSID_DATABASE_CLEANUP=NO_DROP

RESTORE_POINT

Restore point duplication can only be used from the configuration file. Both upper case or lower case are allowed. Restore point duplication can only be used when clone_backup mode is from backup and using a catalog is mandatory. Finally restore point duplication will be ignored if standby option or Point-In-Time recovery (rdate/rtime) is used.

# Duplication done until restore point
RESTORE_POINT=

CHANNEL_NBR

This parameter will be used to create a defined number of channels.

In case of duplication from active knowing a target connection is initialized, both auxiliary and target channels are allocated.

In case of duplication with tape needed auxiliary and target connections are as well allocated.

In case of duplication from backup, as no target connection is made, only auxiliary channels are allocated.

If parameter is kept empty or is less than 1 (so 0 value), as per default, one channel is allocated.

# Number of channel
CHANNEL_NBR=

Duplicate a Database with dbdupli.ksh

Now it's time to start the duplicate of a database:

/u00/app/oracle/local/dmk_dbduplicate [rdbms112] dbdupli.ksh -f
/u00/app/oracle/local/dmk_dbduplicate/etc/refresh_TEST.cfg

The logfiles will be created at:

$DMK_DBDUPLICATE/logs

Last updated