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 terceiro dos exemplos 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 3: Duplicando CDB- Criando Backup Sets em Paralelo durante o Active Database Duplication
O multisection do RMAN fornece desempenho no backup, fazendo os grandes data files serem backing up em paralelos. Várias peças de backup (backup pieces) são criados, com um canal escrevendo separamente para cada uma das peças. Com o Oracle Database 12c Release 1 (12.1), você pode usar os multisection backup sets para transferir os arquivos da origem necessários para realizar o duplicate do banco de dados ativo.
Use a cláusula SECTION SIZE no comando DUPLICATE para criar os backup sets em multisection, para serem usados para o active database duplication. O seguinte comando cria os backup sets em multisection, com o backup piece de 400MB.
No exemplo a seguir, estamos trabalhando inicialmente no CDB chamado "prmcdb" como fonte de dados a ser duplicado para o CDB "dupcdb", como foi apresentado na terceira parte desta série de artigos. Usamos o comando duplicate do RMAN com as seguintes opções:
Opção do Duplicate | CDB |
Tipo do Duplicate | Active Database Duplication |
Método do Duplicate | Pull Based |
Usando o tipo de backup | Backupsets |
Números de Target Channels | SECTION SIZE 400M |
Números de Auxiliary Channels | 1 |
| 2 |
O comando duplicate do RMAN nesse caso é apresentado abaixo:
RMAN>run
{
allocate channel c1 device type disk;
allocate auxiliary channel a1 device type disk;
allocate auxiliary channel a2 device type disk;
duplicate target database to dupcdb
from active database
spfile
parameter_value_convert ='prmcdb','dupcdb'
set db_file_name_convert ='prmcdb','dupcdb'
set log_file_name_convert ='prmcdb','dupcdb'
section size 400M;
}
Descrição do código:
Como se vê a partir do código acima, utilizamos a opção SECTION SIZE 400M dentro do comando duplicate do RMAN. Isso significa que o RMAN utiliza os backup sets para o duplicar o banco de dados origem e também irá criar várias peças de backup com o tamanho é 400M.
Neste caso, o número de target channels (1) é menor do que os auxiliary channels (2), assim, tendo como comportamento a execução do active database duplication utilizando o método Pull-Based. 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 Tue Apr 8 12:50:13 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target sys/*****@prmcdb
connected to target database: PRMCDB (DBID=2508276746)
RMAN> connect auxiliary sys/*****@dupcdb
connected to auxiliary database: DUPCDB (not mounted)
Recovery Manager: Release 12.1.0.1.0 - Production on Tue Apr 8 17:20:01 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
RMAN> run
2> {
3> allocate channel c1 device type disk;
4>
5> allocate auxiliary channel a1 device type disk;
6> allocate auxiliary channel a2 device type disk;
7>
8> duplicate target database to dupcdb
9> from active database
10> spfile
11> parameter_value_convert='prmcdb','dupcdb'
12> set db_file_name_convert='prmcdb','dupcdb'
13> set log_file_name_convert='prmcdb','dupcdb'
14> section size 400M;
15> }
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=43 device type=DISK
allocated channel: a1
channel a1: SID=20 device type=DISK
allocated channel: a2
channel a2: SID=21 device type=DISK
Starting Duplicate Db at 08-APR-14
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 08-APR-14
channel a1: starting datafile backup set restore
channel a1: using network backup set from service prmcdb
channel a1: restoring SPFILE
output file name=/u01/app/oracle/product/12.1.0/dbhome/dbs/spfiledupcdb.ora
channel a1: restore complete, elapsed time: 00:00:01
Finished restore at 08-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
allocated channel: a1
channel a1: SID=19 device type=DISK
allocated channel: a2
channel a2: SID=20 device type=DISK
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
allocated channel: a1
channel a1: SID=7 device type=DISK
allocated channel: a2
channel a2: SID=20 device type=DISK
Starting restore at 08-APR-14
channel a1: starting datafile backup set restore
channel a1: using network backup set from service prmcdb
channel a1: restoring control file
channel a1: 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 08-APR-14
database mounted
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 6 to
"/u01/app/oracle/oradata/dupcdb/users01.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 10 to
"/u01/app/oracle/oradata/dupcdb/prmpdb01/prmpdb01_users01.dbf";
set newname for datafile 28 to
"/u01/app/oracle/oradata/dupcdb/prmpdb02/system01.dbf";
set newname for datafile 29 to
"/u01/app/oracle/oradata/dupcdb/prmpdb02/sysaux01.dbf";
set newname for datafile 30 to
"/u01/app/oracle/oradata/dupcdb/prmpdb02/prmpdb02_users01.dbf";
restore
from service 'prmcdb' section size
400 m clone database
;
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
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 08-APR-14
channel a1: starting datafile backup set restore
channel a1: using network backup set from service prmcdb
channel a1: specifying datafile(s) to restore from backup set
channel a1: restoring datafile 00001 to /u01/app/oracle/oradata/dupcdb/system01.dbf
channel a1: restoring section 1 of 2
channel a2: starting datafile backup set restore
channel a2: using network backup set from service prmcdb
channel a2: specifying datafile(s) to restore from backup set
channel a2: restoring datafile 00003 to /u01/app/oracle/oradata/dupcdb/sysaux01.dbf
channel a2: restoring section 1 of 2
channel a1: restore complete, elapsed time: 00:01:05
channel a1: starting datafile backup set restore
channel a1: using network backup set from service prmcdb
channel a1: specifying datafile(s) to restore from backup set
channel a1: restoring datafile 00001 to /u01/app/oracle/oradata/dupcdb/system01.dbf
channel a1: restoring section 2 of 2
channel a2: restore complete, elapsed time: 00:01:05
channel a2: starting datafile backup set restore
channel a2: using network backup set from service prmcdb
channel a2: specifying datafile(s) to restore from backup set
channel a2: restoring datafile 00003 to /u01/app/oracle/oradata/dupcdb/sysaux01.dbf
channel a2: restoring section 2 of 2
channel a1: restore complete, elapsed time: 00:01:15
channel a1: starting datafile backup set restore
channel a1: using network backup set from service prmcdb
channel a1: specifying datafile(s) to restore from backup set
channel a1: restoring datafile 00004 to /u01/app/oracle/oradata/dupcdb/undotbs01.dbf
channel a1: restoring section 1 of 1
channel a2: restore complete, elapsed time: 00:01:16
channel a2: starting datafile backup set restore
channel a2: using network backup set from service prmcdb
channel a2: specifying datafile(s) to restore from backup set
channel a2: restoring datafile 00005 to /u01/app/oracle/oradata/dupcdb/pdbseed/system01.dbf
channel a2: restoring section 1 of 1
channel a1: restore complete, elapsed time: 00:00:26
channel a1: starting datafile backup set restore
channel a1: using network backup set from service prmcdb
channel a1: specifying datafile(s) to restore from backup set
channel a1: restoring datafile 00006 to /u01/app/oracle/oradata/dupcdb/users01.dbf
channel a1: restoring section 1 of 1
channel a1: restore complete, elapsed time: 00:00:03
channel a1: starting datafile backup set restore
channel a1: using network backup set from service prmcdb
channel a1: specifying datafile(s) to restore from backup set
channel a1: restoring datafile 00007 to /u01/app/oracle/oradata/dupcdb/pdbseed/sysaux01.dbf
channel a1: restoring section 1 of 2
channel a2: restore complete, elapsed time: 00:01:06
channel a2: starting datafile backup set restore
channel a2: using network backup set from service prmcdb
channel a2: specifying datafile(s) to restore from backup set
channel a2: restoring datafile 00007 to /u01/app/oracle/oradata/dupcdb/pdbseed/sysaux01.dbf
channel a2: restoring section 2 of 2
channel a2: restore complete, elapsed time: 00:00:55
channel a2: starting datafile backup set restore
channel a2: using network backup set from service prmcdb
channel a2: specifying datafile(s) to restore from backup set
channel a2: restoring datafile 00008 to /u01/app/oracle/oradata/dupcdb/prmpdb01/system01.dbf
channel a2: restoring section 1 of 1
channel a1: restore complete, elapsed time: 00:01:38
channel a1: starting datafile backup set restore
channel a1: using network backup set from service prmcdb
channel a1: specifying datafile(s) to restore from backup set
channel a1: restoring datafile 00009 to /u01/app/oracle/oradata/dupcdb/prmpdb01/sysaux01.dbf
channel a1: restoring section 1 of 2
channel a2: restore complete, elapsed time: 00:01:03
channel a2: starting datafile backup set restore
channel a2: using network backup set from service prmcdb
channel a2: specifying datafile(s) to restore from backup set
channel a2: restoring datafile 00009 to /u01/app/oracle/oradata/dupcdb/prmpdb01/sysaux01.dbf
channel a2: restoring section 2 of 2
channel a1: restore complete, elapsed time: 00:01:31
channel a1: starting datafile backup set restore
channel a1: using network backup set from service prmcdb
channel a1: specifying datafile(s) to restore from backup set
channel a1: restoring datafile 00010 to /u01/app/oracle/oradata/dupcdb/prmpdb01/prmpdb01_users01.dbf
channel a1: restoring section 1 of 1
channel a1: restore complete, elapsed time: 00:00:03
channel a1: starting datafile backup set restore
channel a1: using network backup set from service prmcdb
channel a1: specifying datafile(s) to restore from backup set
channel a1: restoring datafile 00028 to /u01/app/oracle/oradata/dupcdb/prmpdb02/system01.dbf
channel a1: restoring section 1 of 1
channel a2: restore complete, elapsed time: 00:00:53
channel a2: starting datafile backup set restore
channel a2: using network backup set from service prmcdb
channel a2: specifying datafile(s) to restore from backup set
channel a2: restoring datafile 00029 to /u01/app/oracle/oradata/dupcdb/prmpdb02/sysaux01.dbf
channel a2: restoring section 1 of 2
channel a1: restore complete, elapsed time: 00:01:01
channel a1: starting datafile backup set restore
channel a1: using network backup set from service prmcdb
channel a1: specifying datafile(s) to restore from backup set
channel a1: restoring datafile 00029 to /u01/app/oracle/oradata/dupcdb/prmpdb02/sysaux01.dbf
channel a1: restoring section 2 of 2
channel a2: restore complete, elapsed time: 00:01:20
channel a2: starting datafile backup set restore
channel a2: using network backup set from service prmcdb
channel a2: specifying datafile(s) to restore from backup set
channel a2: restoring datafile 00030 to /u01/app/oracle/oradata/dupcdb/prmpdb02/prmpdb02_users01.dbf
channel a2: restoring section 1 of 1
channel a2: restore complete, elapsed time: 00:00:08
channel a1: restore complete, elapsed time: 00:00:51
Finished restore at 08-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 2028233;
switch clone datafile all;
}
executing Memory Script
Starting restore at 08-APR-14
channel a1: starting archived log restore to default destination
channel a1: using network backup set from service prmcdb
channel a1: restoring archived log
archived log thread=1 sequence=67
channel a2: starting archived log restore to default destination
channel a2: using network backup set from service prmcdb
channel a2: restoring archived log
archived log thread=1 sequence=68
channel a1: restore complete, elapsed time: 00:00:03
channel a2: restore complete, elapsed time: 00:00:03
Finished restore at 08-APR-14
datafile 1 switched to datafile copy
input datafile copy RECID=27 STAMP=844363740 file name=/u01/app/oracle/oradata/dupcdb/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=28 STAMP=844363740 file name=/u01/app/oracle/oradata/dupcdb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=29 STAMP=844363741 file name=/u01/app/oracle/oradata/dupcdb/undotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=30 STAMP=844363742 file name=/u01/app/oracle/oradata/dupcdb/pdbseed/system01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=31 STAMP=844363742 file name=/u01/app/oracle/oradata/dupcdb/users01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=32 STAMP=844363743 file name=/u01/app/oracle/oradata/dupcdb/pdbseed/sysaux01.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=33 STAMP=844363744 file name=/u01/app/oracle/oradata/dupcdb/prmpdb01/system01.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=34 STAMP=844363744 file name=/u01/app/oracle/oradata/dupcdb/prmpdb01/sysaux01.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=35 STAMP=844363745 file name=/u01/app/oracle/oradata/dupcdb/prmpdb01/prmpdb01_users01.dbf
datafile 28 switched to datafile copy
input datafile copy RECID=36 STAMP=844363745 file name=/u01/app/oracle/oradata/dupcdb/prmpdb02/system01.dbf
datafile 29 switched to datafile copy
input datafile copy RECID=37 STAMP=844363746 file name=/u01/app/oracle/oradata/dupcdb/prmpdb02/sysaux01.dbf
datafile 30 switched to datafile copy
input datafile copy RECID=38 STAMP=844363746 file name=/u01/app/oracle/oradata/dupcdb/prmpdb02/prmpdb02_users01.dbf
contents of Memory Script:
{
set until scn 2028681;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 08-APR-14
starting media recovery
archived log for thread 1 with sequence 67 is already on disk as file /u01/app/oracle/fra/DUPCDB/archivelog/2014_04_08/o1_mf_1_67_9n7tw914_.arc
archived log for thread 1 with sequence 68 is already on disk as file /u01/app/oracle/fra/DUPCDB/archivelog/2014_04_08/o1_mf_1_68_9n7tw9fy_.arc
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";
shutdown clone immediate;
}
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 shut down
released channel: c1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/08/2014 17:29:42
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 1 with sequence 66 and starting SCN of 2027471 found to restore
Recovery Manager complete.
Nota Importante: Você pode observar no ultimo output, estamos recebendo um erro. Esse erro é um bug no Oracle 12c Database (12.1.0.1). Este bug foi corrigido com o patch set 12.1.0.2. Como provavelmente já deve saber, o Oracle Database 12c Release 1 (12.1.0.2) foi divulgado no dia 24 de julho de 2014.
Você não obterá esse erro, quando executado esses passos no 12c Release 1 (12.1.0.2).
Esperamos que este artigo tenha sido útil para você. Convidamos a ler a próxima parte desta série de artigos:
Caso 4: Duplicando CDB - Push-Based Active Database Duplication para o CDBJoel 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.