Recover - Dropped Pluggable database (PDB2) with an available RMAN backup
--Environment looks as below:
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Dec 9 18:57:10 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition
Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select name,cdb from v$database;
NAME CDB
--------- ---
ORCL YES
SQL> show pdbs;
CON_ID CON_NAME
OPEN MODE RESTRICTED
----------
------------------------------ ---------- ----------
2
PDB$SEED
READ ONLY NO
3
PDB1
READ WRITE NO
5 PDB2 READ WRITE NO
--Will drop the pluggable database PDB2.
SQL> alter pluggable database PDB2 close;
Pluggable database altered.
SQL> drop pluggable database PDB2 including datafiles;
Pluggable database dropped.
SQL> show pdbs;
CON_ID CON_NAME
OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED
READ ONLY
NO
3 PDB1 READ WRITE NO
--The alert.log shows the drop completion:
[oracle@srvdb01 trace]$ tail -20f alert_orcl.log
handle '/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-1682927172-20231209-01'
2023-12-09T18:59:17.941047+03:00
alter pluggable database PDB2 close
2023-12-09T18:59:18.020014+03:00
PDB2(5):JIT: pid 22876 requesting stop
PDB2(5):Buffer Cache flush started: 5
PDB2(5):Buffer Cache flush finished: 5
Pluggable database PDB2 closed
Completed: alter pluggable database
PDB2 close
2023-12-09T18:59:25.300292+03:00
drop pluggable database PDB2 including
datafiles
2023-12-09T18:59:25.532513+03:00
Deleted file
/u01/app/oracle/oradata/ORCL/pdb2/users01.dbf
Deleted file
/u01/app/oracle/oradata/ORCL/pdb2/temp012023-12-09_18-14-05-608-PM.dbf
Deleted file
/u01/app/oracle/oradata/ORCL/pdb2/undotbs01.dbf
Deleted file
/u01/app/oracle/oradata/ORCL/pdb2/sysaux01.dbf
Deleted file
/u01/app/oracle/oradata/ORCL/pdb2/system01.dbf
Completed: drop pluggable database PDB2 including datafiles
--Will use RMAN RECOVER command to recover this dropped pluggable database PDB2.
RMAN will create an auxiliary database to the specified point in time, will unplug the PDB from this auxiliary and plug the PDB back into the CDB target.
[oracle@srvdb01 aux]$ rman target /
Recovery Manager: Release 19.0.0.0.0 -
Production on Sat Dec 9 19:06:26 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1682927172)
RMAN> set echo on
RMAN> recover pluggable database PDB2 until time "to_date('09-DEC-2023 18:59:00','DD-MON-YYYY HH24:MI:SS')" auxiliary destination '/u01/app/oracle/aux/';
recover pluggable database PDB2 until
time "to_date('09-DEC-2023 18:59:00','DD-MON-YYYY HH24:MI:SS')"
auxiliary destination '/u01/app/oracle/aux/';
Starting recover at 09-DEC-23
using target database control file
instead of recovery catalog
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device
type=DISK
RMAN-05026: warning: presuming following set of tablespaces applies to specified point-in-time
List of tablespaces expected to have
UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1
Creating automatic instance, with SID='Cgml'
initialization parameters used for
automatic instance:
db_name=ORCL
db_unique_name=Cgml_pitr_PDB2_ORCL
compatible=19.0.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_system_trig_enabled=FALSE
sga_target=692M
processes=200
db_create_file_dest=/u01/app/oracle/aux/
log_archive_dest_1='location=/u01/app/oracle/aux/'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance ORCL
Oracle instance started
Total System Global Area 725611152 bytes
Fixed Size 9138832 bytes
Variable Size 201326592 bytes
Database Buffers 507510784 bytes
Redo Buffers 7634944 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until time "to_date('09-DEC-2023
18:59:00','DD-MON-YYYY HH24:MI:SS')";
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone
database';
}
executing Memory Script
executing command: SET until clause
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK
channel ORA_AUX_DISK_1: starting
datafile backup set restore
channel ORA_AUX_DISK_1: restoring
control file
channel ORA_AUX_DISK_1: reading from
backup piece
/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-1682927172-20231209-01
channel ORA_AUX_DISK_1: piece
handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-1682927172-20231209-01
tag=TAG20231209T185648
channel ORA_AUX_DISK_1: restored backup
piece 1
channel ORA_AUX_DISK_1: restore
complete, elapsed time: 00:00:01
output file
name=/u01/app/oracle/aux/ORCL/controlfile/o1_mf_lq94556l_.ctl
Finished restore at 09-DEC-23
sql statement: alter database mount
clone database
contents of Memory Script:
{
# set requested point in time
set until time "to_date('09-DEC-2023
18:59:00','DD-MON-YYYY HH24:MI:SS')";
# set destinations for recovery set and
auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 7 to new;
set newname for datafile 17 to
"/u01/app/oracle/oradata/ORCL/pdb2/system01.dbf";
set newname for datafile 18 to
"/u01/app/oracle/oradata/ORCL/pdb2/sysaux01.dbf";
set newname for datafile 19 to
"/u01/app/oracle/oradata/ORCL/pdb2/undotbs01.dbf";
set newname for datafile 20 to
"/u01/app/oracle/oradata/ORCL/pdb2/users01.dbf";
# restore the tablespaces in the
recovery set and the auxiliary set
restore clone datafile 1, 4, 3, 7, 17, 18, 19, 20;
switch clone datafile all;
}
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
Starting restore at 09-DEC-23
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting
datafile backup set restore
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/aux/ORCL/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring
datafile 00003 to /u01/app/oracle/aux/ORCL/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from
backup piece /u01/app/oracle/backup/cdb_052dkbs3_1_1
channel ORA_AUX_DISK_1: piece
handle=/u01/app/oracle/backup/cdb_052dkbs3_1_1 tag=UPGRADE_DB
channel ORA_AUX_DISK_1: restored backup
piece 1
channel ORA_AUX_DISK_1: restore
complete, elapsed time: 00:00:56
channel ORA_AUX_DISK_1: starting
datafile backup set restore
channel ORA_AUX_DISK_1: specifying
datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring
datafile 00018 to /u01/app/oracle/oradata/ORCL/pdb2/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring
datafile 00019 to /u01/app/oracle/oradata/ORCL/pdb2/undotbs01.dbf
channel ORA_AUX_DISK_1: reading from
backup piece /u01/app/oracle/backup/cdb_072dkbt7_1_1
channel ORA_AUX_DISK_1: piece
handle=/u01/app/oracle/backup/cdb_072dkbt7_1_1 tag=UPGRADE_DB
channel ORA_AUX_DISK_1: restored backup
piece 1
channel ORA_AUX_DISK_1: restore
complete, elapsed time: 00:00:25
channel ORA_AUX_DISK_1: starting
datafile backup set restore
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/aux/ORCL/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring
datafile 00007 to /u01/app/oracle/aux/ORCL/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from
backup piece /u01/app/oracle/backup/cdb_042dkbs3_1_1
channel ORA_AUX_DISK_1: piece
handle=/u01/app/oracle/backup/cdb_042dkbs3_1_1 tag=UPGRADE_DB
channel ORA_AUX_DISK_1: restored backup
piece 1
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: specifying
datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring
datafile 00017 to /u01/app/oracle/oradata/ORCL/pdb2/system01.dbf
channel ORA_AUX_DISK_1: restoring
datafile 00020 to /u01/app/oracle/oradata/ORCL/pdb2/users01.dbf
channel ORA_AUX_DISK_1: reading from
backup piece /u01/app/oracle/backup/cdb_0a2dkbu6_1_1
channel ORA_AUX_DISK_1: piece
handle=/u01/app/oracle/backup/cdb_0a2dkbu6_1_1 tag=UPGRADE_DB
channel ORA_AUX_DISK_1: restored backup
piece 1
channel ORA_AUX_DISK_1: restore
complete, elapsed time: 00:00:25
Finished restore at 09-DEC-23
datafile 1 switched to datafile copy
input datafile copy RECID=8
STAMP=1155150610 file
name=/u01/app/oracle/aux/ORCL/datafile/o1_mf_system_lq947xhd_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=9
STAMP=1155150610 file
name=/u01/app/oracle/aux/ORCL/datafile/o1_mf_undotbs1_lq945f6j_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=10
STAMP=1155150610 file
name=/u01/app/oracle/aux/ORCL/datafile/o1_mf_sysaux_lq945f2p_.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=11
STAMP=1155150610 file
name=/u01/app/oracle/aux/ORCL/datafile/o1_mf_users_lq947xjt_.dbf
contents of Memory Script:
{
# set requested point in time
set until time "to_date('09-DEC-2023
18:59:00','DD-MON-YYYY HH24:MI:SS')";
# online the datafiles restored or
switched
sql clone "alter database
datafile 1 online";
sql clone "alter database
datafile 4 online";
sql clone "alter database
datafile 3 online";
sql clone "alter database
datafile 7 online";
sql clone 'PDB2' "alter database
datafile
17 online";
sql clone 'PDB2' "alter database
datafile
18 online";
sql clone 'PDB2' "alter database
datafile
19 online";
sql clone 'PDB2' "alter database
datafile
20 online";
#recover pdb
recover clone database tablespace "SYSTEM", "UNDOTBS1",
"SYSAUX", "USERS" pluggable database
'PDB2'
delete archivelog;
#open in read write mode
sql clone 'alter database open
resetlogs';
#unplug dropped pdb into temp file
sql clone "alter pluggable
database PDB2 unplug into ''
/u01/app/oracle/product/19.0.0/dbhome_1/dbs/_rm_pdb_pitr_2_Cgml.xml''";
#create pdb using temp file of
recovered pdb
sql "create pluggable database
PDB2 using ''
/u01/app/oracle/product/19.0.0/dbhome_1/dbs/_rm_pdb_pitr_2_Cgml.xml''
nocopy tempfile reuse";
alter pluggable database PDB2 open;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database
datafile 1 online
sql statement: alter database
datafile 4 online
sql statement: alter database
datafile 3 online
sql statement: alter database
datafile 7 online
sql statement: alter database
datafile 17 online
sql statement: alter database
datafile 18 online
sql statement: alter database
datafile 19 online
sql statement: alter database
datafile 20 online
Starting recover at 09-DEC-23
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence
8 is already on disk as file /u01/app/oracle/archive/1_8_1155146439.dbf
archived log for thread 1 with sequence
9 is already on disk as file /u01/app/oracle/archive/1_9_1155146439.dbf
archived log file
name=/u01/app/oracle/archive/1_8_1155146439.dbf thread=1 sequence=8
archived log file
name=/u01/app/oracle/archive/1_9_1155146439.dbf thread=1 sequence=9
media recovery complete, elapsed time:
00:00:00
Finished recover at 09-DEC-23
sql statement: alter database open
resetlogs
sql statement: alter pluggable database
PDB2 unplug into
''/u01/app/oracle/product/19.0.0/dbhome_1/dbs/_rm_pdb_pitr_2_Cgml.xml''
sql statement: create pluggable
database PDB2 using
''/u01/app/oracle/product/19.0.0/dbhome_1/dbs/_rm_pdb_pitr_2_Cgml.xml'' nocopy
tempfile reuse
Statement processed
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file
/u01/app/oracle/product/19.0.0/dbhome_1/dbs/_rm_pdb_pitr_2_Cgml.xml deleted
auxiliary instance file
/u01/app/oracle/aux/ORCL/datafile/o1_mf_sysaux_lq945f2p_.dbf deleted
auxiliary instance file
/u01/app/oracle/aux/ORCL/controlfile/o1_mf_lq94556l_.ctl deleted
Finished recover at 09-DEC-23
-- Pluggable database PDB2 recovered and plugged into target CDB:
[oracle@srvdb01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 -
Production on Sat Dec 9 20:03:41 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition
Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select name,cdb from v$database;
NAME CDB
--------- ---
ORCL YES
SQL> show pdbs;
CON_ID CON_NAME
OPEN MODE RESTRICTED
----------
------------------------------ ---------- ----------
2 PDB$SEED
READ ONLY NO
3 PDB1
READ WRITE NO
4 PDB2
READ WRITE NO
Comments
Post a Comment