Oracle Database 12c: Duplicate em modo ativo com RMAN (Parte IX)

Caso 8: Duplicando PDBs – Duplicando os tablespaces de um PDBs 

Por Joel Perez , Mahir M. Quluzade (OCE) & Flávio Soares (OCE)
Postado em Março 2015

Revisado por Marcelo Pirovar - Solution Architect

Índice do artigos:

 

Vamos ver o oitavo exemplo para a duplicar o bancos de dados com o RMAN em modo ativo.

Antes de ler este artigo, aconselhamos a ler (parte I) desta série de artigos para que você possa ter certeza sobre a teoria relacionada com esta série de artigos. Se você preparou seu hosts de destino como mostra os 7 passos (na parte I), então você pode duplicar banco de dados usando o RMAN.

Caso 8: Duplicando PDBs - Duplicate de tablespaces PDBs
RMAN permite duplicar não só o CBD, mais também você pode duplicar um ou vários PDBs no mesmo comando de DUPLICATE. Além disso, você pode duplicar um conjunto de tablespaces dentro de um PDB. Você precisa estar logado no root do CDB com um usuário que é concedido o privilégio SYSDBA ou SYSBACKUP. A partir disso, você vai ver exemplos de duplicate do Pluggable Databases (PDBs). As opções para duplicar os PDBs são apresentados abaixo:


Opção do DUPLICATE

Explicação

PLUGGABLE DATABASE pdb_name

Duplica os PDBs específicos do CDB. Use uma lista delimitada por vírgula para duplicar vários PDBs.

SKIP PLUGGABLE DATABASE pdb_name

Duplica todos os PDBs do CDB, exceto os especificados pelo PDBs pdb_name. Use uma lista delimitada por vírgula para especificar vários PDBs que devem ser excluídos.

TABLESPACE pdb_name:tablespace_name

Duplica os tablespaces especificado dentro de um PDB. O nome do tablespace deve ser prefixado com o nome do PDB que contém o tablespace. Se você omitir o nome do PDB, a raiz é tomado como padrão.

SKIP TABLESPACE pdb_name:tablespace_name

Duplica todos os tablespace do CDB, exceto os tablespaces especificados no PDB especificado.


No exemplo a seguir, estamos trabalhando inicialmente no CDB chamado "prmcdb" como fonte de dados a ser duplicado para o CDB "dupcdb", como fizemos em outra parte deste artigo. Antes de realizar o duplicate, vamos criar um novo tablespace nos PDBs prmpdb01 e prmpdb02. Os tablespaces PDB01_TBS1 e PDB01_TBS2 criados no PDB prmpdb01 e os tablespaces PDB02_TBS1 e PDB02_TBS2 serão criados no PDB prmpdb02.

[oracle@oel62-ora12c-prm ~]$ export ORACLE_SID=prmcdb
[oracle@oel62-ora12c-prm ~]$ sqlplus / as sysdba
 
SQL*Plus: Release 12.1.0.1.0 Production on Mon Apr 14 11:17:19 2014
 
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
 
SQL> select con_id, tablespace_name from cdb_tablespaces order by  1,2;
 
    CON_ID TABLESPACE_NAME
---------- ------------------------------
         1 SYSAUX
         1 SYSTEM
         1 TEMP
         1 UNDOTBS1
         1 USERS
         2 SYSAUX
         2 SYSTEM
         2 TEMP
         3 SYSAUX
 
    CON_ID TABLESPACE_NAME
---------- ------------------------------
         3 SYSTEM
         3 TEMP
         3 USERS
         4 SYSAUX
         4 SYSTEM
         4 TEMP
         4 USERS
         5 SYSAUX
         5 SYSTEM
 
    CON_ID TABLESPACE_NAME
---------- ------------------------------
         5 TEMP
         5 USERS
 
20 rows selected.
 
SQL> select name from v$datafile;
 
NAME
--------------------------------------------------------------------------
/u01/app/oracle/oradata/prmcdb/system01.dbf
/u01/app/oracle/oradata/prmcdb/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/undotbs01.dbf
/u01/app/oracle/oradata/prmcdb/pdbseed/system01.dbf
/u01/app/oracle/oradata/prmcdb/users01.dbf
/u01/app/oracle/oradata/prmcdb/pdbseed/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/system01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/prmpdb01_users01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb02/system01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb02/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb02/prmpdb02_users01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb03/system01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb03/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb03/prmpdb03_users01.dbf
 
15 rows selected.
 
SQL> alter session set container=prmpdb01;
 
Session altered.
 
SQL> create tablespace PDB01_TBS1 datafile 
'/u01/app/oracle/oradata/prmcdb/prmpdb01/pdb01_tbs1.dbf' size 10M;
 
Tablespace created.
 
SQL> create tablespace PDB01_TBS2 datafile 
'/u01/app/oracle/oradata/prmcdb/prmpdb01/pdb01_tbs2.dbf' size 10M;
 
Tablespace created.
 
SQL> alter session set container=prmpdb02;
 
Session altered.
 
SQL> create tablespace PDB02_TBS1 datafile 
'/u01/app/oracle/oradata/prmcdb/prmpdb02/pdb02_tbs1.dbf' size 10M;
 
Tablespace created.
 
SQL> create tablespace PDB02_TBS2 datafile 
'/u01/app/oracle/oradata/prmcdb/prmpdb02/pdb02_tbs2.dbf' size 10M;
 
Tablespace created.
 
SQL> alter session set container=CDB$ROOT;
 
Session altered.
 
SQL> select con_id, tablespace_name from cdb_tablespaces order by  1,2;
 
    CON_ID TABLESPACE_NAME
---------- ------------------------------
         1 SYSAUX
         1 SYSTEM
         1 TEMP
         1 UNDOTBS1
         1 USERS
         2 SYSAUX
         2 SYSTEM
         2 TEMP
         3 PDB01_TBS1
         3 PDB01_TBS2
         3 SYSAUX
 
    CON_ID TABLESPACE_NAME
---------- ------------------------------
         3 SYSTEM
         3 TEMP
         3 USERS
         4 PDB02_TBS1
         4 PDB02_TBS2
         4 SYSAUX
         4 SYSTEM
         4 TEMP
         4 USERS
         5 SYSAUX
         5 SYSTEM
 
    CON_ID TABLESPACE_NAME
---------- ------------------------------
         5 TEMP
         5 USERS
 
24 rows selected.
 
SQL> select name from v$datafile;
 
NAME
-----------------------------------------------------------------------------
/u01/app/oracle/oradata/prmcdb/system01.dbf
/u01/app/oracle/oradata/prmcdb/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/undotbs01.dbf
/u01/app/oracle/oradata/prmcdb/pdbseed/system01.dbf
/u01/app/oracle/oradata/prmcdb/users01.dbf
/u01/app/oracle/oradata/prmcdb/pdbseed/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/system01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/prmpdb01_users01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb02/system01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb02/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb02/prmpdb02_users01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb03/system01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb03/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb03/prmpdb03_users01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/pdb01_tbs1.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/pdb01_tbs2.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb02/pdb02_tbs1.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb02/pdb02_tbs2.dbf
 
19 rows selected.

Neste caso vamos duplicar o PDB01_TBS1 do PDB prmpdb01. Vamos duplicar com o comando do RMAN, com a opções que se segue:


Opção do Duplicate

TABLESPACE - tablespace prmpdb01:pdb01_tbs1

Tipo do Duplicate

Active Database Duplication

Método do Duplicate

Pull-Based

Usando o tipo de backup

BACKUPSETS   (padrão)

Números de Target Channels

1   (padrão)

Números de Auxiliary Channels

1  (padrão)


Usamos o comando duplicate do RMAN nesse caso, com as seguintes opções:               

duplicate database to dupcdb tablespace prmpdb01:pdb01_tbs1
  from active database 
  spfile 
parameter_value_convert  ='prmcdb','dupcdb' 
set db_file_name_convert  ='prmcdb','dupcdb'
set log_file_name_convert ='prmcdb','dupcdb';

Descrição do código:
Como se vê a partir do código acima, o RMAN irá duplicar o tablespace pbd01_tbs1 do PDB prmpdb01. O RMAN duplica somente o PDB prmpdb01, exclui todos os outros PDBs e duplica somente o específico tablespace, ignorando todos os outros do PDB. os target e auxiliary channels não são alocados de forma explícita. O RMAN aloca apenas um target e um default auxiliary channel (ORA_ DISK_1 and ORA_AUX_DISK_1). O número de target e auxiliary channels são os mesmos. Isso significa que nesse caso o RMAN utilizará o método Pull-Based para o duplicate. Utilizamos também o parâmetros parameter_value_convert e o db{log}_file_name_convert no comando duplicate. O uso desses parâmetros estão explicados na primeira parte (parte I) desta série de artigos.

No output podemos ver um processo normal de duplicate, como sempre foi nas versões anteriores.

Vamos ver este código em ação:

[oracle@oel62-ora12c-prm ~]$ rman
 
 
Recovery Manager: Release 12.1.0.1.0 - Production on Mon Apr 14 11:40:07 2014
 
Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.
 
RMAN> connect target "sys/******@prmcdb as sysdba";
 
connected to target database: PRMCDB (DBID=2508276746)
 
RMAN> connect auxiliary "sys/******@dupcdb as sysdba"; 
 
connected to auxiliary database: DUPCDB (not mounted)
 
RMAN> duplicate database to dupcdb tablespace prmpdb01:pdb01_tbs1
2>  from active database 
3>  spfile 
4>   parameter_value_convert='prmcdb','dupcdb' 
5>   set db_file_name_convert='prmcdb','dupcdb'
6>   set log_file_name_convert='prmcdb','dupcdb';
 
Starting Duplicate Db at 14-APR-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=21 device type=DISK
current log archived
 
contents of Memory Script:
{
   restore clone from service  'prmcdb' spfile to 
 '/u01/app/oracle/product/12.1.0/dbhome/dbs/spfiledupcdb.ora';
   sql clone "alter system set spfile= ''/u01/app/oracle/product/12.1.0/dbhome/dbs/spfiledupcdb.ora''";
}
executing Memory Script
 
Starting restore at 14-APR-14
using channel ORA_AUX_DISK_1
 
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: restoring SPFILE
output file name=/u01/app/oracle/product/12.1.0/dbhome/dbs/spfiledupcdb.ora
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 14-APR-14
 
sql statement: alter system set spfile= ''/u01/app/oracle/product/12.1.0/dbhome/dbs/spfiledupcdb.ora''
 
contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''DUPCDB'' comment=
 ''duplicate'' scope=spfile";
   sql clone "alter system set  audit_file_dest = 
 ''/u01/app/oracle/admin/dupcdb/adump'' comment=
 '''' scope=spfile";
   sql clone "alter system set  control_files = 
 ''/u01/app/oracle/oradata/dupcdb/control01.ctl'', ''/u01/app/oracle/fra/dupcdb/control02.ctl'' comment=
 '''' scope=spfile";
   sql clone "alter system set  dispatchers = 
 ''(PROTOCOL=TCP) (SERVICE=dupcdbXDB)'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_file_name_convert = 
 ''prmcdb'', ''dupcdb'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_file_name_convert = 
 ''prmcdb'', ''dupcdb'' comment=
 '''' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script
 
sql statement: alter system set  db_name =  ''DUPCDB'' comment= ''duplicate'' scope=spfile
 
sql statement: alter system set  audit_file_dest =  ''/u01/app/oracle/admin/dupcdb/adump'' 
comment= '''' scope=spfile
 
sql statement: alter system set  control_files =  ''/u01/app/oracle/oradata/dupcdb/control01.ctl'', 
''/u01/app/oracle/fra/dupcdb/control02.ctl'' comment= '''' scope=spfile
 
sql statement: alter system set  dispatchers =  ''(PROTOCOL=TCP) (SERVICE=dupcdbXDB)'' 
comment= '''' scope=spfile
 
sql statement: alter system set  db_file_name_convert =  ''prmcdb'', ''dupcdb'' 
comment= '''' scope=spfile
 
sql statement: alter system set  log_file_name_convert =  ''prmcdb'', ''dupcdb'' 
comment= '''' scope=spfile
 
Oracle instance shut down
 
connected to auxiliary database (not started)
Oracle instance started
 
Total System Global Area    1219260416 bytes
 
Fixed Size                     2287768 bytes
Variable Size                838862696 bytes
Database Buffers             369098752 bytes
Redo Buffers                   9011200 bytes
 
contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''PRMCDB'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''DUPCDB'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone from service  'prmcdb' primary controlfile;
   alter clone database mount;
}
executing Memory Script
 
sql statement: alter system set  db_name =  ''PRMCDB'' 
comment= ''Modified by RMAN duplicate'' scope=spfile
 
sql statement: alter system set  db_unique_name =  ''DUPCDB'' 
comment= ''Modified by RMAN duplicate'' scope=spfile
 
Oracle instance shut down
 
Oracle instance started
 
Total System Global Area    1219260416 bytes
 
Fixed Size                     2287768 bytes
Variable Size                838862696 bytes
Database Buffers             369098752 bytes
Redo Buffers                   9011200 bytes
 
Starting restore at 14-APR-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 device type=DISK
 
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
output file name=/u01/app/oracle/oradata/dupcdb/control01.ctl
output file name=/u01/app/oracle/fra/dupcdb/control02.ctl
Finished restore at 14-APR-14
 
database mounted
Skipping pluggable database PRMPDB02
Skipping pluggable database PRMPDB03
Automatically adding tablespace SYSTEM
Automatically adding tablespace SYSAUX
Automatically adding tablespace PDB$SEED:SYSTEM
Automatically adding tablespace PDB$SEED:SYSAUX
Automatically adding tablespace PRMPDB01:SYSTEM
Automatically adding tablespace PRMPDB01:SYSAUX
Automatically adding tablespace UNDOTBS1
Checking that duplicated tablespaces are self-contained
Skipping tablespace USERS
Skipping tablespace PRMPDB01:USERS
Skipping tablespace PRMPDB01:PDB01_TBS2
Datafile 28 skipped by request
Datafile 29 skipped by request
Datafile 30 skipped by request
Datafile 31 skipped by request
Datafile 32 skipped by request
Datafile 33 skipped by request
Datafile 36 skipped by request
Datafile 37 skipped by request
 
contents of Memory Script:
{
   set newname for datafile  1 to 
 "/u01/app/oracle/oradata/dupcdb/system01.dbf";
   set newname for datafile  3 to 
 "/u01/app/oracle/oradata/dupcdb/sysaux01.dbf";
   set newname for datafile  4 to 
 "/u01/app/oracle/oradata/dupcdb/undotbs01.dbf";
   set newname for datafile  5 to 
 "/u01/app/oracle/oradata/dupcdb/pdbseed/system01.dbf";
   set newname for datafile  7 to 
 "/u01/app/oracle/oradata/dupcdb/pdbseed/sysaux01.dbf";
   set newname for datafile  8 to 
 "/u01/app/oracle/oradata/dupcdb/prmpdb01/system01.dbf";
   set newname for datafile  9 to 
 "/u01/app/oracle/oradata/dupcdb/prmpdb01/sysaux01.dbf";
   set newname for datafile  34 to 
 "/u01/app/oracle/oradata/dupcdb/prmpdb01/pdb01_tbs1.dbf";
   restore
   from service  'prmcdb'   clone database
   skip forever tablespace  "USERS",
 "PRMPDB01":"USERS",
 "PRMPDB02":"USERS",
 "PRMPDB02":"SYSTEM",
 "PRMPDB02":"SYSAUX",
 "PRMPDB03":"USERS",
 "PRMPDB03":"SYSTEM",
 "PRMPDB03":"SYSAUX",
 "PRMPDB01":"PDB01_TBS2",
 "PRMPDB02":"PDB02_TBS2",
 "PRMPDB02":"PDB02_TBS1"   ;
   sql 'alter system archive log current';
}
executing Memory Script
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
Starting restore at 14-APR-14
using channel ORA_AUX_DISK_1
 
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/dupcdb/system01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:45
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/dupcdb/sysaux01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:35
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/dupcdb/undotbs01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/dupcdb/pdbseed/system01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/dupcdb/pdbseed/sysaux01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/dupcdb/prmpdb01/system01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/dupcdb/prmpdb01/sysaux01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:25
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00034 to /u01/app/oracle/oradata/dupcdb/prmpdb01/pdb01_tbs1.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 14-APR-14
 
sql statement: alter system archive log current
current log archived
 
contents of Memory Script:
{
   restore clone force from service  'prmcdb' 
           archivelog from scn  4866252;
   switch clone datafile all;
}
executing Memory Script
 
Starting restore at 14-APR-14
using channel ORA_AUX_DISK_1
 
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=94
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service prmcdb
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=95
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 14-APR-14
 
datafile 1 switched to datafile copy
input datafile copy RECID=11 STAMP=844861718 file name=/u01/app/oracle/oradata/dupcdb/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=12 STAMP=844861719 file name=/u01/app/oracle/oradata/dupcdb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=13 STAMP=844861719 file name=/u01/app/oracle/oradata/dupcdb/undotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=14 STAMP=844861720 file name=/u01/app/oracle/oradata/dupcdb/pdbseed/system01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=15 STAMP=844861720 file name=/u01/app/oracle/oradata/dupcdb/pdbseed/sysaux01.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=16 STAMP=844861721 file name=/u01/app/oracle/oradata/dupcdb/prmpdb01/system01.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=17 STAMP=844861721 file name=/u01/app/oracle/oradata/dupcdb/prmpdb01/sysaux01.dbf
datafile 34 switched to datafile copy
input datafile copy RECID=18 STAMP=844861722 file name=/u01/app/oracle/oradata/dupcdb/prmpdb01/pdb01_tbs1.dbf
 
contents of Memory Script:
{
   set until scn  4866621;
   recover
   clone database
   skip forever tablespace  "USERS",
 "PRMPDB01":"USERS",
 "PRMPDB02":"USERS",
 "PRMPDB02":"SYSTEM",
 "PRMPDB02":"SYSAUX",
 "PRMPDB03":"USERS",
 "PRMPDB03":"SYSTEM",
 "PRMPDB03":"SYSAUX",
 "PRMPDB01":"PDB01_TBS2",
 "PRMPDB02":"PDB02_TBS2",
 "PRMPDB02":"PDB02_TBS1"    delete archivelog
   ;
}
executing Memory Script
 
executing command: SET until clause
 
Starting recover at 14-APR-14
using channel ORA_AUX_DISK_1
 
Executing: alter database datafile 6 offline drop
Executing: alter database datafile 10 offline drop
Executing: alter database datafile 30 offline drop
Executing: alter database datafile 28 offline drop
Executing: alter database datafile 29 offline drop
Executing: alter database datafile 33 offline drop
Executing: alter database datafile 31 offline drop
Executing: alter database datafile 32 offline drop
Executing: alter database datafile 35 offline drop
Executing: alter database datafile 37 offline drop
Executing: alter database datafile 36 offline drop
starting media recovery
 
archived log for thread 1 with sequence 94 is already on disk as file 
/u01/app/oracle/fra/DUPCDB/archivelog/2014_04_14/o1_mf_1_94_9nq1624x_.arc
archived log for thread 1 with sequence 95 is already on disk as file 
/u01/app/oracle/fra/DUPCDB/archivelog/2014_04_14/o1_mf_1_95_9nq165cy_.arc
archived log file 
name=/u01/app/oracle/fra/DUPCDB/archivelog/2014_04_14/o1_mf_1_94_9nq1624x_.arc thread=1 sequence=94
archived log file 
name=/u01/app/oracle/fra/DUPCDB/archivelog/2014_04_14/o1_mf_1_95_9nq165cy_.arc thread=1 sequence=95
media recovery complete, elapsed time: 00:00:14
Finished recover at 14-APR-14
Oracle instance started
 
Total System Global Area    1219260416 bytes
 
Fixed Size                     2287768 bytes
Variable Size                838862696 bytes
Database Buffers             369098752 bytes
Redo Buffers                   9011200 bytes
 
contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''DUPCDB'' comment=
 ''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
}
executing Memory Script
 
sql statement: alter system set  db_name =  ''DUPCDB'' comment= ''Reset to original value by RMAN'' scope=spfile
 
sql statement: alter system reset  db_unique_name scope=spfile
Oracle instance started
 
Total System Global Area    1219260416 bytes
 
Fixed Size                     2287768 bytes
Variable Size                838862696 bytes
Database Buffers             369098752 bytes
Redo Buffers                   9011200 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUPCDB" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES     1024
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1 ( '/u01/app/oracle/oradata/dupcdb/redo01.log' ) SIZE 50 M  REUSE,
  GROUP   2 ( '/u01/app/oracle/oradata/dupcdb/redo02.log' ) SIZE 50 M  REUSE,
  GROUP   3 ( '/u01/app/oracle/oradata/dupcdb/redo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/u01/app/oracle/oradata/dupcdb/system01.dbf',
  '/u01/app/oracle/oradata/dupcdb/pdbseed/system01.dbf',
  '/u01/app/oracle/oradata/dupcdb/prmpdb01/system01.dbf'
 CHARACTER SET AL32UTF8
 
 
contents of Memory Script:
{
   set newname for tempfile  1 to 
 "/u01/app/oracle/oradata/dupcdb/temp01.dbf";
   set newname for tempfile  2 to 
 "/u01/app/oracle/oradata/dupcdb/pdbseed/pdbseed_temp01.dbf";
   set newname for tempfile  3 to 
 "/u01/app/oracle/oradata/dupcdb/prmpdb01/temp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "/u01/app/oracle/oradata/dupcdb/sysaux01.dbf", 
 "/u01/app/oracle/oradata/dupcdb/undotbs01.dbf", 
 "/u01/app/oracle/oradata/dupcdb/pdbseed/sysaux01.dbf", 
 "/u01/app/oracle/oradata/dupcdb/prmpdb01/sysaux01.dbf", 
 "/u01/app/oracle/oradata/dupcdb/prmpdb01/pdb01_tbs1.dbf";
   switch clone datafile all;
}
executing Memory Script
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
renamed tempfile 1 to /u01/app/oracle/oradata/dupcdb/temp01.dbf in control file
renamed tempfile 2 to /u01/app/oracle/oradata/dupcdb/pdbseed/pdbseed_temp01.dbf in control file
renamed tempfile 3 to /u01/app/oracle/oradata/dupcdb/prmpdb01/temp01.dbf in control file
 
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupcdb/sysaux01.dbf RECID=1 STAMP=844861764
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupcdb/undotbs01.dbf RECID=2 STAMP=844861764
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupcdb/pdbseed/sysaux01.dbf RECID=3 STAMP=844861765
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupcdb/prmpdb01/sysaux01.dbf RECID=4 STAMP=844861766
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupcdb/prmpdb01/pdb01_tbs1.dbf RECID=5 STAMP=844861766
 
datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=844861764 file name=/u01/app/oracle/oradata/dupcdb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=844861764 file name=/u01/app/oracle/oradata/dupcdb/undotbs01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=3 STAMP=844861765 file name=/u01/app/oracle/oradata/dupcdb/pdbseed/sysaux01.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=4 STAMP=844861766 file name=/u01/app/oracle/oradata/dupcdb/prmpdb01/sysaux01.dbf
datafile 34 switched to datafile copy
input datafile copy RECID=5 STAMP=844861766 file name=/u01/app/oracle/oradata/dupcdb/prmpdb01/pdb01_tbs1.dbf
 
contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script
 
database opened
Executing: drop pluggable database "PRMPDB02"
Executing: drop pluggable database "PRMPDB03"
 
contents of Memory Script:
{
   sql clone "alter pluggable database all open";
}
executing Memory Script
 
sql statement: alter pluggable database all open
Dropping offline and skipped tablespaces
Executing: alter database default tablespace system
Executing: drop tablespace "USERS" including contents cascade constraints
Executing: alter database default tablespace system
Executing: drop tablespace "USERS" including contents cascade constraints
Executing: drop tablespace "PDB01_TBS2" including contents cascade constraints
Finished Duplicate Db at 14-APR-14
 
Recovery Manager complete.

Nos podemos conferir o duplicado PDB, no duplicado banco de dados:

[oracle@oel62-ora12c-dup ~]$ export ORACLE_SID=dupcdb
[oracle@oel62-ora12c-dup ~]$ sqlplus / as  sysdba
 
SQL*Plus: Release 12.1.0.1.0 Production on Mon Apr 14 11:56:12 2014
 
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
 
SQL> select name, open_mode from v$pdbs;
 
NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PRMPDB01                       READ WRITE
 
SQL> select con_id, tablespace_name from cdb_tablespaces order by con_id;
 
    CON_ID TABLESPACE_NAME
---------- ------------------------------
         1 SYSTEM
         1 TEMP
         1 UNDOTBS1
         1 SYSAUX
         2 SYSAUX
         2 TEMP
         2 SYSTEM
         3 TEMP
         3 SYSAUX
         3 PDB01_TBS1
         3 SYSTEM
 
11 rows selected.

Esperamos que este artigo tenha sido útil para você. Convidamos a ler a próxima parte desta série de artigos:

Caso 9: Duplicando PDBs – Duplicando de um PDBA e um tablespace em outro PDB 


Joel Pérez é um DBA Especialista (Oracle ACE Director, OCM Cloud Admin. & OCM11g ). Com mais de 14 anos de experiência do mundo Oracle Technology, especializado em arquitetura e implementação de soluções como: Cloud, Alta disponibilidade, Disaster/Recovery, Upgrades, replicação e todos as áreas relacionadas com bancos de dados Oracle. Consultor internacional com deveres, conferências e atividades em mais de 50 países e inúmeros clientes em todo o mundo. Palestrante regular nos eventos Oracle em todo o mundo como: OTN LAD, OTN MENA, OTN APAC e muito mais. Joel sempre foi conhecido por ser pioneiro em tecnologia Oracle desde os primeiros dias de sua carreira sendo o primeiro latino-americano premiado como "OTN Expert" no ano de 2003 pela Oracle Corporation, um dos primeiros "ACE Oracle" no Oracle ACE Program no ano de 2004, um dos primeiros OCP Database Cloud Administrator em todo o mundo no ano de 2013 e como um das maiores realizações profissionais em sua carreira, recentemente ele foi homenageado como o primeiro "OCM Database Cloud Administrator" do mundo.

Mahir M. Quluzade é um DBA Sênior com mais de 10 anos de experiência em banco de dados Oracle com foco principal na alta disponibilidade e soluções de recuperação de desastres (RAC, Data Guard, RMAN, ...). Mahir está atualmente trabalhando no Banco Central da República do Azerbaijão. Ele é um DBA OCP. Mahir é membro fundador do Azerbaijão a Oracle User Group (AZEROUG); também é um blogger. Siga Mahir em seu blog.

Flávio Soares é um Oracle DBA Sênior, Exadata DMA, Troubleshooter e Consultor Oracle, certificado em OCP/OCE RAC. Especialista em Exadata, alta disponibilidade e replicação de dados com soluções Oracle. Flávio disponibiliza frequentes informações para a comunidade Oracle através do seu blog.

Este artigo foi revisto pela equipe de produtos Oracle e está em conformidade com as normas e práticas para o uso de produtos Oracle.