O RMAN (Recovery Manager) permite clonar ou duplicar um banco de dados Oracle a partir de um backup ou de um banco de dados ativo (Active Database Duplication). Neste artigo, demonstrarei como realizar a clonagem de um banco de dados mantendo-o no estado NOOPEN, ou seja, sem executar a abertura do banco de dados após a duplicação.
Essa abordagem pode ser útil em diferentes cenários, como:
- Preparação para upgrade: clonar um banco de dados para realizar os procedimentos necessários antes de uma atualização de versão.
- Migração de ambiente: preparar uma cópia do banco de dados em outro servidor ou infraestrutura sem colocá-la imediatamente em operação.
- Análise e troubleshooting: criar uma cópia para investigar problemas ou validar procedimentos sem afetar o ambiente de produção.
- Testes e validações: preparar um ambiente de testes para execução de procedimentos administrativos antes da abertura do banco de dados.
Neste exemplo, demonstrarei como realizar a duplicação de um banco de dados Oracle utilizando o RMAN com a opção NOOPEN. Com essa opção, o banco de dados duplicado permanecerá no estado MOUNT, sem ser aberto automaticamente ao término do processo de duplicação.
A opção NOOPEN está disponível a partir do Oracle Database 12c, permitindo maior controle sobre as etapas posteriores à clonagem, especialmente em cenários de preparação para upgrades, migrações e validações.
Database de origem:
set lines 200
col DATABASE_HOST for a25;
col DB_UNIQUE_NAME for a25
col HOST_NAME for a15;
col DATABASE_ROLE for a10
col OPEN_MODE for a10
col STARTUP_TIME for a20
alter session set nls_date_format = 'DD/MM/YYYY HH24:MI:SS';
SELECT i.HOST_NAME "DATABASE_HOST" ,
i.INSTANCE_NAME "DB_NAME",
d.db_unique_name "DB_UNIQUE_NAME" ,
d.DATABASE_ROLE " DATABASE_ROLE",
i.VERSION,
d.OPEN_MODE " OPEN_MODE ",
d.LOG_MODE
,STARTUP_TIME
from GV$DATABASE d, gv$instance i
where i.INST_ID=d.INST_ID;DATABASE_HOST DB_NAME DB_UNIQUE_NAME DATABASE_ROLE VERSION OPEN_MODE LOG_MODE STARTUP_TIME
------------------------- ---------------- ------------------------- ---------------- ----------------- -------------------- ------------ --------------------
srv01 lab12c lab12c PRIMARY 12.2.0.1.0 READ WRITE ARCHIVELOG 03/02/2023 09:37:59Executando um backup level 0 com archivelogs do database lab12c:
run
{
configure channel device type disk maxpiecesize 10G format '/u02/backups/12c/backupset/%d_full_%I-%s-%U.bak';
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/backups/12c/backupset/%F';
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
sql "alter system switch logfile";
sql "create pfile = ''/u02/backups/12c/backupset/initlab12c.ora'' from spfile";
BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL=0 DATABASE INCLUDE CURRENT CONTROLFILE TAG='db_full_cf' PLUS ARCHIVELOG TAG='arc_full_cf';
backup current controlfile tag='cf_current_full';
sql "alter system switch logfile";
}[oracle@srv01 oradata]$ rman target /
Recovery Manager: Release 12.2.0.1.0 - Production on Fri Feb 3 09:40:35 2023
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: LAB12C (DBID=1830920858)
RMAN> run
{
configure channel device type disk maxpiecesize 10G format '/u02/backups/12c/backupset/%d_full_%I-%s-%U.bak';
CONFIGURE CO2> 3> 4> NTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/backups/12c/backupset/%F';
CONFIG5> 6> URE RETENTION POLICY TO REDUNDANCY 1;
sql "alter system switch logfile";
sql "create pfile = ''/u02/backups/12c/backupset/initla7> 8> b12c.ora'' from spfile";
BACKUP 9> AS COMPRESSED BACKUPSET INCREMENTAL LEVEL=0 DATABASE INCLUDE CURRENT CONTROLFILE TAG='db_full_cf' PLUS ARCHIVELOG TAG='arc_full_cf';
backup current controlfile tag='cf_current_full';
sql "alter system switch logfile";
}10> 11> 12>
using target database control file instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 10 G FORMAT '/u02/backups/12c/backupset/%d_full_%I-%s-%U.bak';
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 10 G FORMAT '/u02/backups/12c/backupset/%d_full_%I-%s-%U.bak';
new RMAN configuration parameters are successfully stored
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/backups/12c/backupset/%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/backups/12c/backupset/%F';
new RMAN configuration parameters are successfully stored
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters are successfully stored
sql statement: alter system switch logfile
sql statement: create pfile = ''/u02/backups/12c/backupset/initlab12c.ora'' from spfile
Starting backup at 03-FEB-23
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=263 device type=DISK
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=10 RECID=5 STAMP=1115324766
input archived log thread=1 sequence=11 RECID=6 STAMP=1115324778
input archived log thread=1 sequence=12 RECID=7 STAMP=1115324784
input archived log thread=1 sequence=13 RECID=8 STAMP=1115325013
input archived log thread=1 sequence=14 RECID=9 STAMP=1125486540
input archived log thread=1 sequence=15 RECID=10 STAMP=1127813888
input archived log thread=1 sequence=16 RECID=11 STAMP=1127814045
input archived log thread=1 sequence=17 RECID=12 STAMP=1127814045
channel ORA_DISK_1: starting piece 1 at 03-FEB-23
channel ORA_DISK_1: finished piece 1 at 03-FEB-23
piece handle=/u02/backups/12c/backupset/LAB12C_full_1830920858-9-091ji4su_1_1.bak tag=ARC_FULL_CF comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 03-FEB-23
Starting backup at 03-FEB-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/lab12c/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/lab12c/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/lab12c/undotbs01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/lab12c/users01.dbf
channel ORA_DISK_1: starting piece 1 at 03-FEB-23
channel ORA_DISK_1: finished piece 1 at 03-FEB-23
piece handle=/u02/backups/12c/backupset/LAB12C_full_1830920858-10-0a1ji4sv_1_1.bak tag=DB_FULL_CF comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00010 name=/u01/app/oracle/oradata/lab12c/prod/sysaux01.dbf
input datafile file number=00009 name=/u01/app/oracle/oradata/lab12c/prod/system01.dbf
input datafile file number=00011 name=/u01/app/oracle/oradata/lab12c/prod/undotbs01.dbf
input datafile file number=00012 name=/u01/app/oracle/oradata/lab12c/prod/users01.dbf
channel ORA_DISK_1: starting piece 1 at 03-FEB-23
channel ORA_DISK_1: finished piece 1 at 03-FEB-23
piece handle=/u02/backups/12c/backupset/LAB12C_full_1830920858-11-0b1ji4v1_1_1.bak tag=DB_FULL_CF comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/app/oracle/oradata/lab12c/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/lab12c/pdbseed/system01.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/lab12c/pdbseed/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 03-FEB-23
channel ORA_DISK_1: finished piece 1 at 03-FEB-23
piece handle=/u02/backups/12c/backupset/LAB12C_full_1830920858-12-0c1ji50e_1_1.bak tag=DB_FULL_CF comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 03-FEB-23
channel ORA_DISK_1: finished piece 1 at 03-FEB-23
piece handle=/u02/backups/12c/backupset/LAB12C_full_1830920858-13-0d1ji51r_1_1.bak tag=DB_FULL_CF comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 03-FEB-23
Starting backup at 03-FEB-23
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=18 RECID=13 STAMP=1127814207
channel ORA_DISK_1: starting piece 1 at 03-FEB-23
channel ORA_DISK_1: finished piece 1 at 03-FEB-23
piece handle=/u02/backups/12c/backupset/LAB12C_full_1830920858-14-0e1ji520_1_1.bak tag=ARC_FULL_CF comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 03-FEB-23
Starting backup at 03-FEB-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 03-FEB-23
channel ORA_DISK_1: finished piece 1 at 03-FEB-23
piece handle=/u02/backups/12c/backupset/LAB12C_full_1830920858-15-0f1ji521_1_1.bak tag=CF_CURRENT_FULL comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 03-FEB-23
Starting Control File and SPFILE Autobackup at 03-FEB-23
piece handle=/u02/backups/12c/backupset/c-1830920858-20230203-00 comment=NONE
Finished Control File and SPFILE Autobackup at 03-FEB-23
sql statement: alter system switch logfileListando arquivos de backups gerados:
[oracle@srv01 logs]$ ls -lat /u02/backups/12c/backupset
total 1062692
-rw-r----- 1 oracle oinstall 18825216 Feb 3 10:12 c-1830920858-20230203-01
drwxr-xr-x 1 oracle oinstall 1172 Feb 3 10:12 .
-rw-r----- 1 oracle oinstall 34348544 Feb 3 10:12 LAB12C_arc_1830920858-17-0h1ji6ov_1_1.bak
-rw-r----- 1 oracle oinstall 18825216 Feb 3 09:43 c-1830920858-20230203-00
-rw-r----- 1 oracle oinstall 18792448 Feb 3 09:43 LAB12C_full_1830920858-15-0f1ji521_1_1.bak
-rw-r----- 1 oracle oinstall 22016 Feb 3 09:43 LAB12C_full_1830920858-14-0e1ji520_1_1.bak
-rw-r----- 1 oracle oinstall 1114112 Feb 3 09:43 LAB12C_full_1830920858-13-0d1ji51r_1_1.bak
-rw-r----- 1 oracle oinstall 267657216 Feb 3 09:43 LAB12C_full_1830920858-12-0c1ji50e_1_1.bak
-rw-r----- 1 oracle oinstall 269115392 Feb 3 09:42 LAB12C_full_1830920858-11-0b1ji4v1_1_1.bak
-rw-r----- 1 oracle oinstall 425984000 Feb 3 09:41 LAB12C_full_1830920858-10-0a1ji4sv_1_1.bak
-rw-r----- 1 oracle oinstall 7196672 Feb 3 09:40 LAB12C_full_1830920858-9-091ji4su_1_1.bak
-rw-r--r-- 1 oracle oinstall 1255 Feb 3 09:40 initlab12c.ora
Init do banco lab12c que iremos usar no duplicate como modelo:
[oracle@srv01 backupset]$ strings initlab12c.ora
lab12c.__data_transfer_cache_size=0
lab12c.__db_cache_size=1744830464
lab12c.__inmemory_ext_roarea=0
lab12c.__inmemory_ext_rwarea=0
lab12c.__java_pool_size=16777216
lab12c.__large_pool_size=33554432
lab12c.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
lab12c.__pga_aggregate_target=805306368
lab12c.__sga_target=2415919104
lab12c.__shared_io_pool_size=117440512
lab12c.__shared_pool_size=486539264
lab12c.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/lab12c/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_files='/u01/app/oracle/oradata/lab12c/control01.ctl','/u01/app/oracle/recovery_area/lab12c/control02.ctl'
*.db_block_size=8192
*.db_name='lab12c'
*.db_recovery_file_dest='/u01/app/oracle/recovery_area'
*.db_recovery_file_dest_size=12780m
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=lab12cXDB)'
*.enable_pluggable_database=true
*.local_listener='LISTENER_LAB12C'
*.log_archive_dest_1='LOCATION=/u02/backups/12c/archivelog/ MANDATORY'
*.log_archive_format='%t_%s_%r.arc'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=767m
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=2299m
*.undo_tablespace='UNDOTBS1'Init ajustado para usar o duplicate na criação do novo database hml:
[oracle@srv01 backupset]$ cat initlab12c_hml.ora
hml.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.audit_file_dest='/u01/app/oracle/admin/hml/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_files='/u01/app/oracle/oradata/hml/control01.ctl','/u01/app/oracle/recovery_area/hml/control02.ctl'
*.db_block_size=8192
*.db_name='hml' <================
*.db_recovery_file_dest='/u01/app/oracle/recovery_area'
*.db_recovery_file_dest_size=12780m
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=lab12cXDB)'
*.enable_pluggable_database=true
*.log_archive_dest_1='LOCATION=/u02/backups/hml/archivelog/ MANDATORY'
*.log_archive_format='%t_%s_%r.arc'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=767m
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=2299m
*.undo_tablespace='UNDOTBS1'
# CONVERTENDO OS DIRETORIOS DOS DATAFILES DA ORIGEM PARA O NOVO DESTINO
*.db_file_name_convert='/u01/app/oracle/oradata/lab12c/','/u01/app/oracle/oradata/hml/'
*.log_file_name_convert='/u01/app/oracle/oradata/lab12c/','/u01/app/oracle/oradata/hml/'Criando os diretórios necessários para o database hml.
[oracle@srv01 ]$ mkdir -p /u01/app/oracle/admin/hml/adump
[oracle@srv01 ]$ mkdir -p /u01/app/oracle/oradata/hml/
[oracle@srv01 ]$ mkdir -p /u01/app/oracle/recovery_area/hml/
[oracle@srv01 ]$ mkdir -p /u02/backups/hml/archivelog/Iniciando o database hml com o init criado em nomount:
[oracle@srv01 ~]$ export ORACLE_SID=hml
[oracle@srv01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Feb 3 11:28:28 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='/u02/backups/12c/scripts/initlab12c_hml.ora';
ORACLE instance started.
Total System Global Area 2415918568 bytes
Fixed Size 9137640 bytes
Variable Size 520093696 bytes
Database Buffers 1879048192 bytes
Redo Buffers 7639040 bytes
SQL> exit
[oracle@srv01 scripts]$ ps aux | grep smon
oracle 24649 0.0 0.7 2797700 58572 ? Ss 09:56 0:00 ora_smon_hmlDuplicando o database, informei uma data e horário especifico para o upgrade da 12C para 19C, o parâmetro responsável pela não abertura do banco com o resetlogs é o NOOPEN.
[oracle@srv01 oradata]$ export NLS_DATE_FORMAT='DD/MM/YYYY HH24:MI:SS'
rman auxiliary / msglog /u02/backups/12c/logs/clonando_base_$HOJE.spool << EOF
RUN
{
set until time "to_date('03/02/2023 10:10:00','DD/MM/YYYY HH24:MI:SS')";
allocate auxiliary channel c1 type disk ;
duplicate target database to hml NOOPEN backup location='/u02/backups/12c/backupset';
}
EOF[oracle@srv01 logs]$ cat clonando_base_.spool
Recovery Manager: Release 19.0.0.0.0 - Production on Fri Feb 3 11:29:39 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to auxiliary database: HML (not mounted)
RMAN> 2> 3> 4> 5> 6>
executing command: SET until clause
allocated channel: c1
channel c1: SID=21 device type=DISK
Starting Duplicate Db at 03/02/2023 11:29:40
searching for database ID
found backup of database ID 1830920858
contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 2415918568 bytes
Fixed Size 9137640 bytes
Variable Size 520093696 bytes
Database Buffers 1879048192 bytes
Redo Buffers 7639040 bytes
allocated channel: c1
channel c1: SID=255 device type=DISK
contents of Memory Script:
{
sql clone "alter system set db_name =
''LAB12C'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''hml'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile from '/u02/backups/12c/backupset/c-1830920858-20230203-00';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''LAB12C'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''hml'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 2415918568 bytes
Fixed Size 9137640 bytes
Variable Size 520093696 bytes
Database Buffers 1879048192 bytes
Redo Buffers 7639040 bytes
allocated channel: c1
channel c1: SID=255 device type=DISK
Starting restore at 03/02/2023 11:30:51
channel c1: restoring control file
channel c1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/hml/control01.ctl
output file name=/u01/app/oracle/recovery_area/hml/control02.ctl
Finished restore at 03/02/2023 11:30:52
database mounted
contents of Memory Script:
{
set until scn 1985379;
set newname for datafile 1 to
"/u01/app/oracle/oradata/hml/system01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/hml/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/hml/undotbs01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/hml/pdbseed/system01.dbf";
set newname for datafile 6 to
"/u01/app/oracle/oradata/hml/pdbseed/sysaux01.dbf";
set newname for datafile 7 to
"/u01/app/oracle/oradata/hml/users01.dbf";
set newname for datafile 8 to
"/u01/app/oracle/oradata/hml/pdbseed/undotbs01.dbf";
set newname for datafile 9 to
"/u01/app/oracle/oradata/hml/prod/system01.dbf";
set newname for datafile 10 to
"/u01/app/oracle/oradata/hml/prod/sysaux01.dbf";
set newname for datafile 11 to
"/u01/app/oracle/oradata/hml/prod/undotbs01.dbf";
set newname for datafile 12 to
"/u01/app/oracle/oradata/hml/prod/users01.dbf";
restore
clone database
;
}
executing Memory Script
executing command: SET until clause
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 03/02/2023 11:31:00
channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00001 to /u01/app/oracle/oradata/hml/system01.dbf
channel c1: restoring datafile 00003 to /u01/app/oracle/oradata/hml/sysaux01.dbf
channel c1: restoring datafile 00004 to /u01/app/oracle/oradata/hml/undotbs01.dbf
channel c1: restoring datafile 00007 to /u01/app/oracle/oradata/hml/users01.dbf
channel c1: reading from backup piece /u02/backups/12c/backupset/LAB12C_full_1830920858-10-0a1ji4sv_1_1.bak
channel c1: piece handle=/u02/backups/12c/backupset/LAB12C_full_1830920858-10-0a1ji4sv_1_1.bak tag=DB_FULL_CF
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:01:15
channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00005 to /u01/app/oracle/oradata/hml/pdbseed/system01.dbf
channel c1: restoring datafile 00006 to /u01/app/oracle/oradata/hml/pdbseed/sysaux01.dbf
channel c1: restoring datafile 00008 to /u01/app/oracle/oradata/hml/pdbseed/undotbs01.dbf
channel c1: reading from backup piece /u02/backups/12c/backupset/LAB12C_full_1830920858-12-0c1ji50e_1_1.bak
channel c1: piece handle=/u02/backups/12c/backupset/LAB12C_full_1830920858-12-0c1ji50e_1_1.bak tag=DB_FULL_CF
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:45
channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00009 to /u01/app/oracle/oradata/hml/prod/system01.dbf
channel c1: restoring datafile 00010 to /u01/app/oracle/oradata/hml/prod/sysaux01.dbf
channel c1: restoring datafile 00011 to /u01/app/oracle/oradata/hml/prod/undotbs01.dbf
channel c1: restoring datafile 00012 to /u01/app/oracle/oradata/hml/prod/users01.dbf
channel c1: reading from backup piece /u02/backups/12c/backupset/LAB12C_full_1830920858-11-0b1ji4v1_1_1.bak
channel c1: piece handle=/u02/backups/12c/backupset/LAB12C_full_1830920858-11-0b1ji4v1_1_1.bak tag=DB_FULL_CF
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:45
Finished restore at 03/02/2023 11:33:45
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=12 STAMP=1127820825 file name=/u01/app/oracle/oradata/hml/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=13 STAMP=1127820825 file name=/u01/app/oracle/oradata/hml/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=14 STAMP=1127820826 file name=/u01/app/oracle/oradata/hml/undotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=15 STAMP=1127820826 file name=/u01/app/oracle/oradata/hml/pdbseed/system01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=16 STAMP=1127820826 file name=/u01/app/oracle/oradata/hml/pdbseed/sysaux01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=17 STAMP=1127820826 file name=/u01/app/oracle/oradata/hml/users01.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=18 STAMP=1127820826 file name=/u01/app/oracle/oradata/hml/pdbseed/undotbs01.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=19 STAMP=1127820826 file name=/u01/app/oracle/oradata/hml/prod/system01.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=20 STAMP=1127820826 file name=/u01/app/oracle/oradata/hml/prod/sysaux01.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=21 STAMP=1127820826 file name=/u01/app/oracle/oradata/hml/prod/undotbs01.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=22 STAMP=1127820827 file name=/u01/app/oracle/oradata/hml/prod/users01.dbf
contents of Memory Script:
{
set until time "to_date('FEB 03 2023 10:10:00', 'MON DD YYYY HH24:MI:SS')";
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 03/02/2023 11:33:48
starting media recovery
archived log for thread 1 with sequence 18 is already on disk as file /u02/backups/12c/backupset/1_18_1090420830.arc
archived log for thread 1 with sequence 19 is already on disk as file /u02/backups/12c/backupset/1_19_1090420830.arc
archived log file name=/u02/backups/12c/backupset/1_18_1090420830.arc thread=1 sequence=18
archived log file name=/u02/backups/12c/backupset/1_19_1090420830.arc thread=1 sequence=19
channel c1: starting archived log restore to default destination
channel c1: restoring archived log
archived log thread=1 sequence=20
channel c1: restoring archived log
archived log thread=1 sequence=21
channel c1: reading from backup piece /u02/backups/12c/backupset/LAB12C_arc_1830920858-17-0h1ji6ov_1_1.bak
channel c1: piece handle=/u02/backups/12c/backupset/LAB12C_arc_1830920858-17-0h1ji6ov_1_1.bak tag=ARC_$HOJE
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:01
archived log file name=/u02/backups/hml/archivelog/1_20_1090420830.arc thread=1 sequence=20
channel clone_default: deleting archived log(s)
archived log file name=/u02/backups/hml/archivelog/1_20_1090420830.arc RECID=11 STAMP=1127820830
archived log file name=/u02/backups/hml/archivelog/1_21_1090420830.arc thread=1 sequence=21
channel clone_default: deleting archived log(s)
archived log file name=/u02/backups/hml/archivelog/1_21_1090420830.arc RECID=12 STAMP=1127820830
media recovery complete, elapsed time: 00:00:04
Finished recover at 03/02/2023 11:33:54
released channel: c1
Oracle instance started
Total System Global Area 2415918568 bytes
Fixed Size 9137640 bytes
Variable Size 520093696 bytes
Database Buffers 1879048192 bytes
Redo Buffers 7639040 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''HML'' 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 = ''HML'' 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 2415918568 bytes
Fixed Size 9137640 bytes
Variable Size 520093696 bytes
Database Buffers 1879048192 bytes
Redo Buffers 7639040 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "HML" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/hml/redo01.log' ) SIZE 200 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/hml/redo02.log' ) SIZE 200 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/hml/redo03.log' ) SIZE 200 M REUSE
DATAFILE
'/u01/app/oracle/oradata/hml/system01.dbf',
'/u01/app/oracle/oradata/hml/pdbseed/system01.dbf',
'/u01/app/oracle/oradata/hml/prod/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/hml/temp01.dbf";
set newname for tempfile 2 to
"/u01/app/oracle/oradata/hml/pdbseed/temp012021-12-04_14-41-29-982-PM.dbf";
set newname for tempfile 3 to
"/u01/app/oracle/oradata/hml/prod/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/hml/sysaux01.dbf",
"/u01/app/oracle/oradata/hml/undotbs01.dbf",
"/u01/app/oracle/oradata/hml/pdbseed/sysaux01.dbf",
"/u01/app/oracle/oradata/hml/users01.dbf",
"/u01/app/oracle/oradata/hml/pdbseed/undotbs01.dbf",
"/u01/app/oracle/oradata/hml/prod/sysaux01.dbf",
"/u01/app/oracle/oradata/hml/prod/undotbs01.dbf",
"/u01/app/oracle/oradata/hml/prod/users01.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/hml/temp01.dbf in control file
renamed tempfile 2 to /u01/app/oracle/oradata/hml/pdbseed/temp012021-12-04_14-41-29-982-PM.dbf in control file
renamed tempfile 3 to /u01/app/oracle/oradata/hml/prod/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/hml/sysaux01.dbf RECID=1 STAMP=1127820867
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/hml/undotbs01.dbf RECID=2 STAMP=1127820867
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/hml/pdbseed/sysaux01.dbf RECID=3 STAMP=1127820867
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/hml/users01.dbf RECID=4 STAMP=1127820867
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/hml/pdbseed/undotbs01.dbf RECID=5 STAMP=1127820867
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/hml/prod/sysaux01.dbf RECID=6 STAMP=1127820867
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/hml/prod/undotbs01.dbf RECID=7 STAMP=1127820867
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/hml/prod/users01.dbf RECID=8 STAMP=1127820867
datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=1127820867 file name=/u01/app/oracle/oradata/hml/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=1127820867 file name=/u01/app/oracle/oradata/hml/undotbs01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=1127820867 file name=/u01/app/oracle/oradata/hml/pdbseed/sysaux01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=4 STAMP=1127820867 file name=/u01/app/oracle/oradata/hml/users01.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=5 STAMP=1127820867 file name=/u01/app/oracle/oradata/hml/pdbseed/undotbs01.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=6 STAMP=1127820867 file name=/u01/app/oracle/oradata/hml/prod/sysaux01.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=7 STAMP=1127820867 file name=/u01/app/oracle/oradata/hml/prod/undotbs01.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=8 STAMP=1127820867 file name=/u01/app/oracle/oradata/hml/prod/users01.dbf
Leaving database unopened, as requested
Finished Duplicate Db at 03/02/2023 11:34:28
RMAN>
Recovery Manager complete.
Database hml disponível para upgrade ou testes com status de mount sem execução do resetlogs:
set lines 200
col DATABASE_HOST for a25;
col DB_UNIQUE_NAME for a25
col HOST_NAME for a15;
col DATABASE_ROLE for a10
col OPEN_MODE for a10
col STARTUP_TIME for a20
alter session set nls_date_format = 'DD/MM/YYYY HH24:MI:SS';
SELECT i.HOST_NAME "DATABASE_HOST" ,
i.INSTANCE_NAME "DB_NAME",
d.db_unique_name "DB_UNIQUE_NAME" ,
d.DATABASE_ROLE " DATABASE_ROLE",
i.VERSION,
d.OPEN_MODE " OPEN_MODE ",
d.LOG_MODE
,STARTUP_TIME
from GV$DATABASE d, gv$instance i
where i.INST_ID=d.INST_ID;DATABASE_HOST DB_NAME DB_UNIQUE_NAME DATABASE_ROLE VERSION OPEN_MODE LOG_MODE STARTUP_TIME
------------------------- ---------------- ------------------------- ---------------- ----------------- -------------------- ------------ --------------------
srv01 hml HML PRIMARY 19.0.0.0.0 MOUNTED ARCHIVELOG 03/02/2023 11:34:15
Conclusão
A utilização do RMAN com a opção NOOPEN oferece maior flexibilidade e controle durante o processo de duplicação de um database Oracle. Ao manter o database duplicado no estado MOUNT, é possível executar procedimentos adicionais antes de sua abertura, como ajustes de configuração, validações e preparação para upgrades de versão.
Esse recurso, disponível a partir do Oracle Database 12c, é especialmente útil em ambientes que exigem maior controle sobre as etapas de clonagem e preparação de bancos de dados.
Com isso, podemos utilizar o RMAN não apenas para criar cópias de bancos de dados, mas também para preparar ambientes de forma controlada, segura e alinhada às necessidades de cada cenário.