Tuesday, 13 October 2015

Recovery of Tablespace / Datafile in PDB

PDB tablepsace / datafile restore.

Manually removing an datafile of an PDB to mitigate failure.

SQL> ! rm -f /oracle/product/oradata/sec_cdb/hrdept/users01.dbf

SQL> alter pluggable database hrdepts close;

Pluggable database altered.

SQL> alter pluggable database hrdepts open;
alter pluggable database hrdepts open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 10 - see DBWR trace file
ORA-01110: data file 10: '/oracle/product/oradata/sec_cdb/hrdept/users01.dbf'


SQL> select file#, CHECKPOINT_CHANGE# from V$datafile;

     FILE# CHECKPOINT_CHANGE#
---------- ------------------
         4            3631418
         8            3632915
         9            3632915
        10            3632915

SQL> select name, open_mode from V$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
HRDEPTS                        MOUNTED




[oracle@rhel11gr2rac1 bkp_seccdb]$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Tue Aug 25 09:59:57 2015

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

connected to target database: SEC_CDB (DBID=54313082)

RMAN> list backup of tablespace hrdepts:users;

using target database control file instead of recovery catalog

List of Backup Sets
===================
--
--

RMAN> restore tablespace hrdepts:users;

Starting restore at 25-AUG-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=45 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=65 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00010 to /oracle/product/oradata/sec_cdb/hrdept/users01.dbf
channel ORA_DISK_1: reading from backup piece /oracle/bkp_seccdb/bkp_cold_1kqfe1ql_1_1_20150824
channel ORA_DISK_1: piece handle=/oracle/bkp_seccdb/bkp_cold_1kqfe1ql_1_1_20150824 tag=TAG20150824T182943
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
Finished restore at 25-AUG-15


RMAN> recover tablespace hrdepts:users;


Starting recover at 25-AUG-15
using channel ORA_DISK_1
using channel ORA_DISK_2

starting media recovery

archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oraInventory/fast_recovery_area/SEC_CDB/archivelog/2015_08_25/o1_mf_1_1_bxqd78ff_.arc
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oraInventory/fast_recovery_area/SEC_CDB/archivelog/2015_08_25/o1_mf_1_2_bxqdc248_.arc
archived log for thread 1 with sequence 3 is already on disk as file /u01/app/oraInventory/fast_recovery_area/SEC_CDB/archivelog/2015_08_25/o1_mf_1_3_bxqdc2z5_.arc
archived log for thread 1 with sequence 4 is already on disk as file /u01/app/oraInventory/fast_recovery_area/SEC_CDB/archivelog/2015_08_25/o1_mf_1_4_bxqdc694_.arc
archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oraInventory/fast_recovery_area/SEC_CDB/archivelog/2015_08_25/o1_mf_1_1_bxqkcj1m_.arc
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oraInventory/fast_recovery_area/SEC_CDB/archivelog/2015_08_25/o1_mf_1_2_bxqlfhnt_.arc
archived log file name=/u01/app/oraInventory/fast_recovery_area/SEC_CDB/archivelog/2015_08_25/o1_mf_1_1_bxqd78ff_.arc thread=1 sequence=1
archived log file name=/u01/app/oraInventory/fast_recovery_area/SEC_CDB/archivelog/2015_08_25/o1_mf_1_2_bxqdc248_.arc thread=1 sequence=2
archived log file name=/u01/app/oraInventory/fast_recovery_area/SEC_CDB/archivelog/2015_08_25/o1_mf_1_3_bxqdc2z5_.arc thread=1 sequence=3
archived log file name=/u01/app/oraInventory/fast_recovery_area/SEC_CDB/archivelog/2015_08_25/o1_mf_1_4_bxqdc694_.arc thread=1 sequence=4
media recovery complete, elapsed time: 00:00:01
Finished recover at 25-AUG-15


RMAN> exit

[oracle@rhel11gr2rac1 bkp_seccdb]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Tue Aug 25 10:02:07 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options



SQL> alter session set container=hrdepts;

Session altered.

SQL> alter pluggable database hrdepts open;
alter pluggable database hrdepts open
*
ERROR at line 1:
ORA-01113: file 9 needs media recovery
ORA-01110: data file 9: '/oracle/product/oradata/sec_cdb/hrdept/sysaux01.dbf'


--- !!! its not opening...

SQL> select file#, CHECKPOINT_CHANGE# from V$datafile;

     FILE# CHECKPOINT_CHANGE#
---------- ------------------
         4            3631418
         8            3632915
         9            3632915
        10            3632915



SQL> select file#, name, CHECKPOINT_CHANGE# from V$datafile_header;

     FILE# NAME                                                   CHECKPOINT_CHANGE#
---------- ---------------------------------------------------          ------------------
         4 /oracle/product/oradata/sec_cdb/undotbs01.dbf                3631418
         8 /oracle/product/oradata/sec_cdb/hrdept/system01.dbf          3631418
         9 /oracle/product/oradata/sec_cdb/hrdept/sysuax01.dbf          3631418
        10 /oracle/product/oradata/sec_cdb/hrdept/user01.dbf            3632915


From here we could see that the user01 data file has been applied with more changes than the other datafiles pertaining to that pdb. While restoring the users Tablespace the pdb is in mount state, while recovering the tablespace it is applied more changes to the users Tablespace than other table spaces.


Connec to rman and recover the other tabelspace..

RMAN> recover tablespace hrdepts:sysaux, hrdepts:system;

Starting recover at 25-AUG-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=44 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=59 device type=DISK

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 25-AUG-15


SQL> alter session set container=hrdepts;

Session altered.

SQL> alter pluggable database hrdepts open;

Pluggable database altered.


Now the pdb got opened.
Note: - If the PDB was in open mode when the tablespace is corrupted, we can offline the tablespace and can perform the recovery.

No comments:

Post a Comment