14 Cloning Oracle Databases and Pluggable Databases
Enterprise Manager Cloud Control enables you to clone databases using the Full Clone method, or by using the classic cloning wizard which enables you clone databases using RMAN backup, staging areas, or an existing backup.
This chapter outlines the following procedures which you can use to create a database clone. For other advanced cloning methods, see Enterprise Manager Cloud Administration Guide.
Creating a Full Clone Database
To create a Full Clone database, you can use either of the following solutions:
Creating a Full Clone Database Using the Clone Wizard
To create a full clone database, follow these steps:
Creating a Full Clone Database Using EM CLI
Database Cloning Using EM CLI
To create a full clone of a database you will need to execute thedb_clone_management
verb. See the following verb sample with parameters:emcli db_clone_management
-createFullClone
-target_name="<DB_target_name>"
-target_type="<oracle_database/rac_database>"
-clone_type="<LIVE/POINT_IN_TIME>"
-input_file="<Input_file_path>"
Furthermore you can view the different parameters that need to be included in an input file for a live clone, or a point in time clone; and also the different parameters needed when cloning a Single Instance Database or a RAC Database Clone. To view this information you will need to run the db_clone_management
with the -print_properties
flag:emcli db_clone_management
-createFullClone
-target_name="<DB_target_name>"
-target_type="<oracle_database/rac_database>"
-clone_type="<LIVE/POINT_IN_TIME>"
-print_properties
Note:
If the source database is TDE enabled, then you must also specify theSRC_WALLET_PWD
, WALLET_SOURCE_SECRET
and DEST_WALLET_PWD
properties.
Database Cloning Using Pre and Post Scripts
The following is a list of accepted Deployment Procedure Variables that can be incorporated into Pre and Post scripts for Database cloning workflows. For more information on Pre and Post scripts see: Custom Pre and Post Scripts for Fleet OperationsVariable Name | Description |
---|---|
SRC_DB_TARGET_NAME |
Source database target name |
SRC_DB_TARGET_TYPE |
Source database target type |
COMMON_GLOBAL_DB_NAME |
Global database name of clone |
COMMON_DB_SID |
Clone database SID
Note: UseCOMMON_DB_SID to obtain the Database Unique Name of a cloned database. Databases cloned via the workflow will have the Database Unique Name equal to the value of its SID.
|
DB_TARGET_NAME |
Name of the clone database target |
DB_TARGET_DISPLAY_NAME |
Display name of the clone database target |
DATABASE_TYPE |
Name of the clone database.
Values: |
TARGET_HOST_LIST |
Destination host name |
ORACLE_HOME_LOC |
Destination Oracle Home location |
ORACLE_BASE_LOC |
Destination Oracle Base location |
DB_STORAGE_TYPE |
Destination storage type.
Values: |
DB_FILE_LOC |
Destination database files storage location |
FLASH_REC_AREA |
Location at destination where recovery related files will be created |
FLASH_REC_AREA_SIZE |
Fast Recovery area size |
ARCHIVE_LOG_MODE |
Indicates if the clone database is in ARCHIVELOG mode
|
LISTENER_PORT |
Listener port with which the clone database is configured |
DB_TEMPLATE_STAGE |
Temporary work directory at the destination |
ENABLE_DATA_MASK |
Indicates if data masking definition is applied on clone database |
Sample Variables:
COMMON_GLOBAL_DB_NAME=CLONEDB
COMMON_DB_SID=CLONEDB
DATABASE_TYPE=dbTypeSI
DB_STORAGE_TYPE=FS
DB_FILE_LOC=/scratch/app/oradata
FLASH_REC_AREA=/scratch/user/app/fra
FLASH_REC_AREA_SIZE=3780
ARCHIVE_LOG_MODE=YES
LISTENER_PORT=<Port number>
DB_TEMPLATE_STAGE=/tmp
SRC_DB_TARGET_NAME=xyz.example.com
SRC_DB_TARGET_TYPE=oracle_database
ORACLE_BASE_LOC=/scratch/app/base
ORACLE_HOME_LOC=/scratch/app/product/<DB Version>/dbhome_1
ORACLE_HOME_NAME=OraDBHome_Example
DB_TARGET_NAME=clonedb.xyz.example.com
TARGET_HOST_LIST=desthost.example.com
CONFIGURE_WITH_ORACLE_RESTART=<Y/N>
FRA_STORAGE_TYPE=FS
DEGREE_OF_PARALLELISM=8
ENABLE_DATA_MASK=<True/False>
DB_TARGET_DISPLAY_NAME=SAMPLE_CloneDB
Verify Status of a Database Clone
To verify the status of the database clone creation, execute the verb emcli get_instance_status -instance={instance GUID}
.
Refresh a Cloned Database
Prerequisites for Refreshing a Cloned Database
- The cloned database or Test Master should have been created using Enterprise Manager's deployment procedure. Procedure execution must have successfully completed.
- SSA plugin must be installed in Enterprise Manager and the OracleCloud for Database license pack must be enabled for the database target.
- If a database was marked as clone using the Add button in the Clone Management dashboard the refresh feature will not be available for said database.
- If a Test Master database is created on an Exadata machine (for Exadata Sparse Clones), the refresh feature will not be available for said database.
Refreshing a Cloned Database
- Go to Setup and select Extensibility, and then click Plugins.
- From Servers, Storage and Network menu, deploy the Oracle Virtualization plugin on the Management Server and Management Agents.
- From the Cloud menu, deploy the Oracle Cloud Application plugin on the Management Server.
- Navigate to Oracle Database and click Cloning.
- Click Cloning Management, and then select a cloned database from the list.
- Click Refresh.
Creating a Full Clone Pluggable Database
There are two methods to create a Full Clone Pluggable Database, you can use the Clone Wizard in Enterprise Manager or via command line with EM CLI.
- Creating a Full Clone Pluggable Database Using the Clone Wizard
- Creating a Full Clone Pluggable Database Using EMCLI
If you are managing a PDB on OCI resources make sure that all OCI required prerequistes and discovery have been performed. For more information, see: (Optional) Deploying Agents on OCI Resources.
Note:
From Enterprise Manager 13.4 Release Update 3 onwards users will have the ability to clone and upgrade Pluggable Databases (PDB) by plugging a PDB into a higher version Container Database (CDB), the PDB will be automatically upgraded to the higher CDB version.Creating a Full Clone Pluggable Database Using the Clone Wizard
You can create a full clone of a PDB using the new Clone PDB Wizard. To create a full clone PDB, follow these steps:
Creating a Full Clone Pluggable Database Using EMCLI
Pluggable Database Cloning using EMCLI
To create a full clone of a pluggable database, execute the verbemcli pdb_clone_management -input_file=data:/xyz/sdf/pdb_clone.props
, where pdb_clone.props
is the properties file.
Sample properties file (pdb_clone.props):
SRC_PDB_TARGET=cdb_prod_PDB SRC_HOST_CREDS=NC_HOST_SCY:SYCO SRC_CDB_CREDS=NC_HOST_SYC:SYCO SRC_WORK_DIR=/tmp/source DEST_HOST_CREDS=NC_SLCO_SSH:SYS DEST_LOCATION=/scratch/sray/app/sray/cdb_tm/HR_TM_PDB6 DEST_CDB_TARGET=cdb_tm DEST_CDB_TYPE=oracle_database DEST_CDB_CREDS=NC_HOST_SYC:SYCO DEST_PDB_NAME=HR_TM_PDB6
Note:
- If you are creating a full clone PDB on Oracle cloud, wherein both the destination PDB and the source PDB are in different CDBs, while both the CDBs are on Oracle Cloud, then ensure that the source PDB is in read-write mode. This is necessary since a database link is created in the destination CDB for cloning the PDB, and a temporary user is created in the source PDB for using the database link. If there is an existing database link in the destination CDB that connects to the source PDB, then use the parameter EXISTING_DB_LINK_NAME to provide the database link name in the properties file.
- If the PDB full clone (on-premise) needs to be performed using a backup, then the following parameters should be added in the properties file.
BACKUP_TYPE=RMAN DEST_STAGE_DIR=/tmp/bkp_common
If the temporary backup location is shared across source and destination, then add the SKIP_DATA_TRANSFER parameter and set it to 'Y'. For example,SKIP_DATA_TRANSFER=Y
. This indicates that the data transfer step should be skipped in the clone procedure. - If the source database is TDE enabled and of version 12.2 and above, then you must also specify the
DEST_WALLET_PWD
property. If the source database is TDE enabled and of a version prior to 12.2, then you must specify theSRC_WALLET_PWD
,WALLET_TRANSPORT_SECRET
andDEST_WALLET_PWD
properties.
Pluggable Database Cloning Using Pre and Post Scripts
The following is a list of accepted Deployment Procedure Variables that can be incorporated into Pre and Post scripts for Pluggable Database cloning workflows. For more information on Pre and Post scripts see: Custom Pre and Post Scripts for Fleet OperationsVariable Name | Description |
---|---|
SRC_HOST |
Source host name |
SRC_CDB_TARGET |
Source CDB target name |
SRC_CDB_TYPE |
Source CDB target type.
Values: |
SRC_CDB_NAME |
Source CDB name |
SRC_CDB_SID |
Source CDB SID |
SRC_PDB_NAME |
Source PDB name |
SRC_DATABASE_VERSION |
Source CDB version |
SRC_ORACLE_HOME |
Source Oracle Home location |
DEST_HOST |
Destination host name |
DEST_CDB_TARGET |
Destination CDB target name |
DEST_CDB_TYPE |
Destination CDB target type.
Values: |
DEST_PDB_NAME |
Destination PDB name (clone) |
DEST_CDB_NAME |
Destination CDB name |
DEST_CDB_SID |
Destination CDB SID |
DEST_PDB_DISPLAY_NAME |
Display name of the clone PDB target |
DEST_PDB_ADMIN_NAME |
Destination PDB administrator |
DEST_DATABASE_VERSION |
Destination CDB version |
CREATE_FILE_DEST |
Destination PDB datafiles storage location |
DEST_WORK_DIR |
Work directory on the destination host |
DEST_ORACLE_HOME |
Destination Oracle Home location |
LOGGING_TYPE |
Destination PDB logging clause |
SRC_PDB_ORIG_STATE |
Original state of the Source PDB |
Sample Variables:
SRC_HOST=xyz.example.com
SRC_CDB_TARGET=SAMPLE_CDB1
SRC_CDB_TYPE=oracle_database
SRC_PDB_TARGET=SAMPLE_PDB1
SRC_CDB_NAME=SAMPLE_CDB1
SRC_CDB_SID=CDB1
SRC_PDB_NAME=PDB1
SRC_DATABASE_VERSION=<DB Version>
SRC_ORACLE_HOME=/scratch/app/product/<DB Version>/dbhome_1
DEST_HOST=abc.example.com
DEST_CDB_TARGET=SAMPLE_CDB2
DEST_CDB_TYPE=oracle_database
DEST_PDB_NAME=SAMPLE_PDB2
DEST_CDB_NAME=CDB2
DEST_CDB_SID=CDB2
DEST_PDB_DISPLAY_NAME=SAMPLE_Clone2_PDB
DEST_PDB_ADMIN_NAME=PDBADMIN
DEST_DATABASE_VERSION=<DB Version>
DEST_LOCATION=/scratch/app/oradata/EMEA_CL2
DEST_WORK_DIR=/tmp
DEST_ORACLE_HOME=/scratch/appk/product/<DB Version>/dbhome_1
CREATE_FILE_DEST=/scratch/app/oradata/SAMPLE_PDB2
LOGGING_TYPE=LOGGING
SRC_PDB_ORIG_STATE=READ WRITE
Relocation Database Cloning Using Pre and Post Scripts
The following is a list of accepted Deployment Procedure Variables that can be incorporated into Pre and Post scripts for Pluggable Database relocation cloning workflows. For more information on Pre and Post scripts see: Custom Pre and Post Scripts for Fleet OperationsVariable Name | Description |
---|---|
SRC_PDB_TARGET_NAME |
Source PDB target name |
SRC_CDB_TARGET_NAME |
Source CDB target name |
SRC_CDB_TARGET_TYPE |
Source CDB target type.
Values: |
SRC_PDB_NAME |
Source PDB name |
SRC_PDB_MODE |
State of the Source PDB |
SRC_ORACLE_HOME_LOC |
Source Oracle Home location |
SRC_CDB_VERSION |
Source CDB version |
RELOCATE_TYPE |
Mechanism of PDB relocation |
AVAILABILITY |
Availability mode |
DEST_PDB_NAME |
Destination PDB name |
DEST_PDB_DISPLAY_NAME |
Display name of the relocated PDB target |
DEST_CDB_TARGET_NAME |
Destination CDB target name |
DEST_CDB_TARGET_TYPE |
Destination CDB target type.
Values: |
DB_LINK_NAME |
Name of the Database Link used for PDB relocation |
DEST_WORK_DIR |
Work directory on the destination host |
STORAGE_LOCATION |
Destination PDB datafiles storage location |
LOGGING_TYPE |
Destination PDB logging clause |
DEST_HOST_NAME |
Destination host name |
DEST_ORACLE_HOME_LOC |
Destination Oracle Home location |
DEST_CDB_VERSION |
Destination CDB version |
Sample Variables:
SRC_PDB_TARGET_NAME=PDB1_SAMPLE
SRC_CDB_TARGET_NAME=CDB1_SAMPLE
SRC_CDB_TARGET_TYPE=oracle_database
RELOCATE_TYPE=USING_DBLINK
AVAILABILITY=NORMAL
DEST_PDB_NAME=PDB2_SAMPLE
DEST_PDB_DISPLAY_NAME=PDB2_SAMPLE
DEST_CDB_TARGET_NAME=CDB2_SAMPLE
DEST_CDB_TARGET_TYPE=oracle_database
DB_LINK_NAME=LINK<LINK NUMBER>
DEST_WORK_DIR=/tmp/BKP_STAGE
STORAGE_LOCATION=/scratch/app/oradata
LOGGING_TYPE=LOGGING
SRC_PDB_NAME=PDB1_SAMPLE
SRC_PDB_MODE=READ WRITE
SRC_ORACLE_HOME_LOC=/scratch/app/product/<DB VERSION>/dbhome_1
SRC_CDB_VERSION=<DB VERSION>
DEST_HOST_NAME=abc.sample.com
DEST_ORACLE_HOME_LOC=/s