Cloning Databases using Pluggable Features

Cloning Databases using Pluggable Features

Prerequisites

  • A useful backup set from your source database accessible at your target server.
  • A pfile initialization file (Use something as simple as the below example for your AUXILIARY instance)

DB_NAME=AUXCD
CONTROL_FILES=('+DATA_DG','+FRA_DG')
DB_CREATE_FILE_DEST='+DATA_DG'
DB_FILE_NAME_CONVERT=('+DATA','+DATA_DG','+FRA','+FRA_DG')
LOG_ARCHIVE_DEST='+FRA_DG'
LOG_FILE_NAME_CONVERT=('+DATA','+DATA_DG','+FRA','+FRA_DG')
ENABLE_PLUGGABLE_DATABASE=TRUE
CLUSTER_DATABASE=FALSE
COMPATIBLE='12.2.0.1.0'
UNDO_TABLESPACE='UNDOTBS1'
DB_FILES=5000
MEMORY_TARGET=10G
PGA_AGGREGATE_TARGET=5G
SGA_MAX_SIZE=5G
SGA_TARGET=0
SHARED_POOL_RESERVED_SIZE=5000B        

At your target server, start the Auxiliary Container database:

[oracle@TARGET_HOST tmp]$ export ORACLE_SID=AUXCDB
[oracle@TARGET_HOST tmp]$ sqlplus / as sysdba

SQL>startup nomount pfile ='/var/tmp/initauxcdb.ora' force        

Restore your container and pluggables from your backup into your Auxiliary Instance:

[oracle@TARGET_HOST tmp] rman auxiliary 

run {
allocate auxiliary channel dupe1 type disk;
allocate auxiliary channel dupe2 type disk;
allocate auxiliary channel dupe3 type disk;
allocate auxiliary channel dupe4 type disk;
duplicate database to auxcdb
pluggable database SOURCEPDB1, root backup location '+FRA/AUXCDB/BACKUPSET/'
nofilenamecheck;
}        

You can restore one or multiple pluggables at the same time, by informing their names as:

duplicate database to auxcdb
pluggable database SOURCEPDB1,SOURCEPDB2,SOURCEPDB3 root backup location '+FRA/AUXCDB/BACKUPSET/'
nofilenamecheck;        

Extract the Pluggable databases from Auxiliary Container:

[oracle@TARGET_HOST tmp]$ export ORACLE_SID=AUXCDB
[oracle@TARGET_HOST tmp]$ sqlplus / as sysdba

SQL>show parameter db_name

SQL>alter pluggable database SOURCE_PDB close immediate;

SQL>alter pluggable database SOURCE_PDB unplug into '/var/tmp/SOURCE_PDB_aux.xml';

SQL>drop pluggable database SOURCE_PDB keep datafiles;

SQL>shutdown abort;        

Plug the recently unplugged PDBs into your target CDB:

You can choose to create copies or replace some existing PDB by deleting it before the plugging task.

[oracle@TARGET_HOST tmp]$ export ORACLE_SID=PRODCDB
[oracle@TARGET_HOST tmp]$ sqlplus / as sysdba

SQL> show parameter db_name

NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?TYPE? ? ? ? VALUE
------------------------------------ ----------- --------------------
db_name? ? ? ? ? ? ? ? ? ? ? ? ? ? ? string? ? ? PRODCDB

SQL>alter pluggable database PRODPDB1 close immediate instances=all;

Pluggable database altered.

SQL>drop pluggable database PRODPDB1 including datafiles; 

Pluggable database dropped.

SQL>create pluggable database PRODPDB1 using '/var/tmp/SOURCE_PDB_aux.xml' tempfile reuse move;

Pluggable database created.

SQL>alter pluggable database PRODPDB1 open instances=all;

Pluggable database altered.        

If we need to handle environment with Data Guard, we can use this article.

要查看或添加评论,请登录

Raul Pessoa, MBA的更多文章

社区洞察

其他会员也浏览了