RMAN DUPLICATE a PDB to an existing CDB
La duplicazione di un db tipicamente serve per creare un db da testare e successivamente apportare le modifiche sul db sorgente. Può essere duplicato un intero CDB, solo il root o un PDB.
In questo post duplicheremo tramite RMAN un pdb dal container CDB19L01 al container CDB19L02.
PREREQUISITI
In questo post duplicheremo tramite RMAN un pdb dal container CDB19L01 al container CDB19L02.
Il database è una versione 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.3.0.0.0.
PREREQUISITI
- Il parametro di inizializzazione COMPATIBLE sul CDB sorgente e di destinazione deve essere settato almeno a 18.0.0
SQL> show parameter COMPATIBLE
- Il CDB sorgente e auxiliary (duplicate) devono usare “local undo”
SQL> select * from database_properties where lower(property_name) ='local_undo_enabled';
PROPERTY_NAME PROPERTY_VALUE DESCRIPTION
-------------- -------------- -----------------------------------------------------
LOCAL_UNDO_ENABLED TRUE true if local undo is enabled
- Il PDB da duplicare deve essere in stato read-only o read-write
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDL01 READ WRITE NO
- Il CDB target sul quale deve essere duplicato il PDB deve essere in modalità read-write
SQL> select name, open_mode from v$database;
NAME OPEN_MODE
--------- -------------------------------
CDB19L02 READ WRITE
- Il CDB target deve usare il server parameter file (spfile)
SQL> show parameter spfile
NAME TYPE VALUE
--------------------------------------------------------------------- ----------- ------------------------------
spfile string /u01/app/oracle/product/19.0.0/dbhome_1/dbs/spfileCDB19L02.ora
- Il CDB target deve avere il parametro di inizializzazione REMOTE_RECOVERY_FILE_DEST popolato
SQL> show parameter remote_recovery_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_recovery_file_dest string /u01/app/oracle/fast_recovery_area
- Verificare che il parametro ENABLE_PLUGGABLE_DATABASE è ipostato a TRUE.
SQL> show parameter ENABLE_PLUGGABLE_DATABASE
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
enable_pluggable_database boolean TRUE
on TARGET DATABASE (CDB19L02)
Collegarsi ad RMAN come root del CDB auxiliary (o target):
FROM ACTIVE DATABASE
NOFILENAMECHECK;
Verifica che il pdb sia stato duplicato e sia in stato read write.
Nel caso di prima ho impostato il parameter file DB_FILE_NAME_CONVERT nel spfile del CDB target ma se il container target non lo contiene, occorre creare le nuove directory in cui duplicare il pdb e scrivere esplicitamente il parametro all’iterno del comando "rman duplicate".
on TARGET DATABASE (CDB19L02)
mkdir -p /u01/app/oracle/oradata/CDB19L02/
mkdir -p /u01/app/oracle/fast_recovery_area
$ export ORACLE_SID=CDB19L02
$ sqlplus ‘/as sysdba’
SQL> alter system set remote_recovery_file_dest='/u01/app/oracle/fast_recovery_area';
$ rman target sys/xxxxx0@CDB19L01 auxiliary sys/xxxxx0@CDB19L02
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Apr 27 12:03:35 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB19L01 (DBID=440264890)
connected to auxiliary database: CDB19L02 (DBID=382418914)
RMAN> DUPLICATE PLUGGABLE DATABASE RCATPDB as RCATPDB02 TO CDB19L02
DB_FILE_NAME_CONVERT('/u01/app/oracle/oradata/CDB19L01/rcatpdb/','/u01/app/oracle/oradata/CDB19L02/rcatpdb02/')
SQL> show parameter COMPATIBLE
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
compatible string 19.0.0
------------------------------------ ----------- ------------------------------
compatible string 19.0.0
- Il CDB sorgente e auxiliary (duplicate) devono usare “local undo”
SQL> select * from database_properties where lower(property_name) ='local_undo_enabled';
PROPERTY_NAME PROPERTY_VALUE DESCRIPTION
-------------- -------------- -----------------------------------------------------
LOCAL_UNDO_ENABLED TRUE true if local undo is enabled
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDL01 READ WRITE NO
SQL> select name, open_mode from v$database;
NAME OPEN_MODE
--------- -------------------------------
CDB19L02 READ WRITE
- Il CDB target deve usare il server parameter file (spfile)
SQL> show parameter spfile
NAME TYPE VALUE
--------------------------------------------------------------------- ----------- ------------------------------
spfile string /u01/app/oracle/product/19.0.0/dbhome_1/dbs/spfileCDB19L02.ora
- Il CDB target deve avere il parametro di inizializzazione REMOTE_RECOVERY_FILE_DEST popolato
SQL> show parameter remote_recovery_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_recovery_file_dest string /u01/app/oracle/fast_recovery_area
- Verificare che il parametro ENABLE_PLUGGABLE_DATABASE è ipostato a TRUE.
SQL> show parameter ENABLE_PLUGGABLE_DATABASE
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
enable_pluggable_database boolean TRUE
Collegarsi ad RMAN come root del CDB auxiliary (o target):
$ rman target sys/xxxxx0@CDB19L01 auxiliary sys/xxxxx0@CDB19L02
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Apr 27 12:03:35 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB19L01 (DBID=440264890)
connected to auxiliary database: CDB19L02 (DBID=382418914)
FROM ACTIVE DATABASE
NOFILENAMECHECK;
Starting Duplicate PDB at 26-APR-21
using channel ORA_AUX_DISK_1
current log archived
………………..
Finished Duplicate PDB at 26-APR-21
Verifica che il pdb sia stato duplicato e sia in stato read write.
on TARGET DATABASE (CDB19L02)
$ export ORACLE_SID=CDB19L02
$ sqlplus ‘/as sysdba’
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- -----------------------
2 PDB$SEED READ ONLY NO
3 PDL02 READ WRITE NO
$ export ORACLE_SID=CDB19L02
$ sqlplus ‘/as sysdba’
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- -----------------------
2 PDB$SEED READ ONLY NO
3 PDL02 READ WRITE NO
Nel caso di prima ho impostato il parameter file DB_FILE_NAME_CONVERT nel spfile del CDB target ma se il container target non lo contiene, occorre creare le nuove directory in cui duplicare il pdb e scrivere esplicitamente il parametro all’iterno del comando "rman duplicate".
on TARGET DATABASE (CDB19L02)
mkdir -p /u01/app/oracle/oradata/CDB19L02/
mkdir -p /u01/app/oracle/fast_recovery_area
$ export ORACLE_SID=CDB19L02
$ sqlplus ‘/as sysdba’
SQL> alter system set remote_recovery_file_dest='/u01/app/oracle/fast_recovery_area';
$ rman target sys/xxxxx0@CDB19L01 auxiliary sys/xxxxx0@CDB19L02
Recovery Manager: Release 19.0.0.0.0 - Production on Tue Apr 27 12:03:35 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB19L01 (DBID=440264890)
connected to auxiliary database: CDB19L02 (DBID=382418914)
RMAN> DUPLICATE PLUGGABLE DATABASE RCATPDB as RCATPDB02 TO CDB19L02
DB_FILE_NAME_CONVERT('/u01/app/oracle/oradata/CDB19L01/rcatpdb/','/u01/app/oracle/oradata/CDB19L02/rcatpdb02/')
FROM ACTIVE DATABASE;
Starting Duplicate PDB at 27-APR-21
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=52 device type=DISK
current log archived
...............................
………………….
Performing import of metadata...
Finished Duplicate PDB at 27-APR-21
Starting Duplicate PDB at 27-APR-21
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=52 device type=DISK
current log archived
...............................
………………….
Performing import of metadata...
Finished Duplicate PDB at 27-APR-21