【Q&A】12C OCP 1z0-060 QUESTION 8: Performing Complete Recovery of a Tablespace in the CDB




  • QUESTION 8

    Your multitenant container (CDB) containing three pluggable databases (PDBs) is running in ARCHIVELOG mode. You find that the SYSAUX tablespace is corrupted in the root container. The steps to recover the tablespace are as follows:
       1. Mount the CDB.
       2. Close all the PDBs.
       3. Open the database.
       4. Apply the archive redo logs.
       5. Restore the data file.
       6. Take the SYSAUX tablespace offline.
       7. Place the SYSAUX tablespace online.
       8. Open all the PDBs with RESETLOGS.
       9. Open the database with RESETLOGS.
       10. Execute the command SHUTDOWN ABORT.
    Which option identifies the correct sequence to recover the SYSAUX tablespace?

    A. 6,5,4,7
    B. 10,1,2,5,8
    C. 10,1,2,5,4,9,8
    D. 10,1,5,8,10

    【题目示意】
    本题考察的是CDB中的SYSAUX表空间完全恢复。

    【解析】
    在数据库已经open的情况下,某些非关键数据文件发生损坏。只需要在保证数据库其他数据文件可用的状态下,对损坏的文件或损坏文件所在的表空间进行restore和recover操作。不需要关闭数据库,再进行恢复。在restore之前,要求表空间处于offline状态。

    【实验】
    1.修改数据库为归档模式

    [oracle@dbstyle ~]$ sqlplus / as sysdba

    SQL*Plus: Release 12.1.0.1.0 Production on Mon Aug 11 14:58:41 2014

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

    Connected to an idle instance.

    SYS@DBSTYLE> startup
    ORACLE instance started.

    Total System Global Area 2121183232 bytes
    Fixed Size          2290360 bytes
    Variable Size        1308626248 bytes
    Database Buffers      805306368 bytes
    Redo Buffers            4960256 bytes
    Database mounted.
    Database opened.
    SYS@DBSTYLE> shu immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SYS@DBSTYLE> startup mount
    ORACLE instance started.

    Total System Global Area 2121183232 bytes
    Fixed Size                 2290360 bytes
    Variable Size        1308626248 bytes
    Database Buffers             805306368 bytes
    Redo Buffers            4960256 bytes
    Database mounted.
    SYS@DBSTYLE> alter database archivelog;

    Database altered.

    SYS@DBSTYLE> alter database open;

    Database altered.

    SYS@DBSTYLE> alter system switch logfile;

    System altered.

    2.使用RMAN备份数据库

    SYS@DBSTYLE> !rman

    Recovery Manager: Release 12.1.0.1.0 - Production on Mon Aug 11 15:00:13 2014

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

    RMAN> connect target /

    connected to target database: DBSTYLE (DBID=2767578829)

    RMAN> backup database;

    Starting backup at 11-AUG-14
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=50 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00005 name=/u01/app/oracle/oradata/DBSTYLE/undotbs01.dbf
    input datafile file number=00001 name=/u01/app/oracle/oradata/DBSTYLE/system01.dbf
    input datafile file number=00003 name=/u01/app/oracle/oradata/DBSTYLE/sysaux01.dbf
    input datafile file number=00006 name=/u01/app/oracle/oradata/DBSTYLE/users01.dbf
    channel ORA_DISK_1: starting piece 1 at 11-AUG-14
    channel ORA_DISK_1: finished piece 1 at 11-AUG-14
    piece handle=/u01/app/oracle/fast_recovery_area/DBSTYLE/backupset/2014_08_11/o1_mf_nnndf_TAG20140811T150021_9yjtj5z5_.bkp tag=TAG20140811T150021 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:26
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00008 name=/u01/app/oracle/oradata/DBSTYLE/DBS/sysaux01.dbf
    input datafile file number=00007 name=/u01/app/oracle/oradata/DBSTYLE/DBS/system01.dbf
    input datafile file number=00009 name=/u01/app/oracle/oradata/DBSTYLE/DBS/DBS_users01.dbf
    channel ORA_DISK_1: starting piece 1 at 11-AUG-14
    channel ORA_DISK_1: finished piece 1 at 11-AUG-14
    piece handle=/u01/app/oracle/fast_recovery_area/DBSTYLE/FDD32A078F321802E0430A50A8C0F4FF/backupset/2014_08_11/o1_mf_nnndf_TAG20140811T150021_9yjtjz65_.bkp tag=TAG20140811T150021 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00004 name=/u01/app/oracle/oradata/DBSTYLE/pdbseed/sysaux01.dbf
    input datafile file number=00002 name=/u01/app/oracle/oradata/DBSTYLE/pdbseed/system01.dbf
    channel ORA_DISK_1: starting piece 1 at 11-AUG-14
    channel ORA_DISK_1: finished piece 1 at 11-AUG-14
    piece handle=/u01/app/oracle/fast_recovery_area/DBSTYLE/FDD22BF463BC0F53E0430A50A8C0EDD2/backupset/2014_08_11/o1_mf_nnndf_TAG20140811T150021_9yjtk68h_.bkp tag=TAG20140811T150021 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
    Finished backup at 11-AUG-14

    Starting Control File and SPFILE Autobackup at 11-AUG-14
    piece handle=/u01/app/oracle/fast_recovery_area/DBSTYLE/autobackup/2014_08_11/o1_mf_s_855327661_9yjtkff8_.bkp comment=NONE
    Finished Control File and SPFILE Autobackup at 11-AUG-14

    RMAN> list backup;


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


    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    1       Full    2.09G      DISK        00:00:16     11-AUG-14      
            BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20140811T150021
            Piece Name: /u01/app/oracle/fast_recovery_area/DBSTYLE/backupset/2014_08_11/o1_mf_nnndf_TAG20140811T150021_9yjtj5z5_.bkp
      List of Datafiles in backup set 1
      File LV Type Ckp SCN    Ckp Time  Name
      ---- -- ---- ---------- --------- ----
      1       Full 1564193    11-AUG-14 /u01/app/oracle/oradata/DBSTYLE/system01.dbf
      3       Full 1564193    11-AUG-14 /u01/app/oracle/oradata/DBSTYLE/sysaux01.dbf
      5       Full 1564193    11-AUG-14 /u01/app/oracle/oradata/DBSTYLE/undotbs01.dbf
      6       Full 1564193    11-AUG-14 /u01/app/oracle/oradata/DBSTYLE/users01.dbf

    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    2       Full    762.73M    DISK        00:00:04     11-AUG-14      
            BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20140811T150021
            Piece Name: /u01/app/oracle/fast_recovery_area/DBSTYLE/FDD32A078F321802E0430A50A8C0F4FF/backupset/2014_08_11/o1_mf_nnndf_TAG20140811T150021_9yjtjz65_.bkp
      List of Datafiles in backup set 2
      Container ID: 3, PDB Name: DBS
      File LV Type Ckp SCN    Ckp Time  Name
      ---- -- ---- ---------- --------- ----
      7       Full 1563088    11-AUG-14 /u01/app/oracle/oradata/DBSTYLE/DBS/system01.dbf
      8       Full 1563088    11-AUG-14 /u01/app/oracle/oradata/DBSTYLE/DBS/sysaux01.dbf
      9       Full 1563088    11-AUG-14 /u01/app/oracle/oradata/DBSTYLE/DBS/DBS_users01.dbf

    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    3       Full    761.49M    DISK        00:00:04     11-AUG-14      
            BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20140811T150021
            Piece Name: /u01/app/oracle/fast_recovery_area/DBSTYLE/FDD22BF463BC0F53E0430A50A8C0EDD2/backupset/2014_08_11/o1_mf_nnndf_TAG20140811T150021_9yjtk68h_.bkp
      List of Datafiles in backup set 3
      Container ID: 2, PDB Name: PDB$SEED
      File LV Type Ckp SCN    Ckp Time  Name
      ---- -- ---- ---------- --------- ----
      2       Full 1539785    10-JUL-14 /u01/app/oracle/oradata/DBSTYLE/pdbseed/system01.dbf
      4       Full 1539785    10-JUL-14 /u01/app/oracle/oradata/DBSTYLE/pdbseed/sysaux01.dbf

    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    4       Full    17.20M     DISK        00:00:00     11-AUG-14      
            BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20140811T150101
            Piece Name: /u01/app/oracle/fast_recovery_area/DBSTYLE/autobackup/2014_08_11/o1_mf_s_855327661_9yjtkff8_.bkp
      SPFILE Included: Modification time: 11-AUG-14
      SPFILE db_unique_name: DBSTYLE
      Control File Included: Ckp SCN: 1565204      Ckp time: 11-AUG-14

    3.删除sysaux01.dbf数据文件,模拟sysaux表空间损坏

    [oracle@dbstyle DBSTYLE]$ rm -f sysaux01.dbf

    4.使用RMAN进行restore操作,此时由于表空间没有离线,因此无法进行restore

    RMAN> restore tablespace sysaux;

    Starting restore at 11-AUG-14
    using channel ORA_DISK_1

    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 00003 to /u01/app/oracle/oradata/DBSTYLE/sysaux01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DBSTYLE/backupset/2014_08_11/o1_mf_nnndf_TAG20140811T150021_9yjtj5z5_.bkp
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of restore command at 08/11/2014 15:18:45
    ORA-19870: error while restoring backup piece /u01/app/oracle/fast_recovery_area/DBSTYLE/backupset/2014_08_11/o1_mf_nnndf_TAG20140811T150021_9yjtj5z5_.bkp
    ORA-19573: cannot obtain exclusive enqueue for datafile 3

    5.将SYSAUX表空间离线,此时需要使用offline immediate命令

    [oracle@dbstyle ~]$ sqlplus / as sysdba

    SQL*Plus: Release 12.1.0.1.0 Production on Mon Aug 11 15:01:27 2014

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


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

    SYS@DBSTYLE> alter tablespace sysaux offline;
    alter tablespace sysaux offline
    *
    ERROR at line 1:
    ORA-01116: error in opening database file 3
    ORA-01110: data file 3: '/u01/app/oracle/oradata/DBSTYLE/sysaux01.dbf'
    ORA-27041: unable to open file
    Linux-x86_64 Error: 2: No such file or directory
    Additional information: 3

    SYS@DBSTYLE> alter tablespace sysaux offline immediate;

    Tablespace altered.

    SYS@DBSTYLE> select tablespace_name,status from dba_tablespaces;

    TABLESPACE_NAME            STATUS
    ------------------------------ ---------
    SYSTEM                 ONLINE
    SYSAUX                 OFFLINE
    UNDOTBS1               ONLINE
    TEMP                   ONLINE
    USERS                  ONLINE

    6.再次使用RMAN恢复表空间

    RMAN> restore tablespace sysaux;

    Starting restore at 11-AUG-14
    using channel ORA_DISK_1

    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 00003 to /u01/app/oracle/oradata/DBSTYLE/sysaux01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DBSTYLE/backupset/2014_08_11/o1_mf_nnndf_TAG20140811T150021_9yjtj5z5_.bkp
    channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DBSTYLE/backupset/2014_08_11/o1_mf_nnndf_TAG20140811T150021_9yjtj5z5_.bkp tag=TAG20140811T150021
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
    Finished restore at 11-AUG-14

    RMAN> recover tablespace sysaux;

    Starting recover at 11-AUG-14
    using channel ORA_DISK_1

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

    Finished recover at 11-AUG-14

    RMAN> alter tablespace sysaux online;

    Statement processed

    RMAN>

    7.SYSAUX表空间恢复正常

    SYS@DBSTYLE> select tablespace_name,status from dba_tablespaces;

    TABLESPACE_NAME            STATUS
    ------------------------------ ---------
    SYSTEM                 ONLINE
    SYSAUX                 ONLINE
    UNDOTBS1               ONLINE
    TEMP                   ONLINE
    USERS                  ONLINE

    SYS@DBSTYLE>

    【小结】
    无论CDB或者PDB,如果是非关键表空间发生损坏,对数据库影响最小的处理方法就是,让损坏的表空间离线,然后进行restore和recovery,进而使表空间恢复正常。因此A选项最合理。

    【答案】 A


    相关参考
    http://docs.oracle.com/database/121/BRADV/rcmcomre.htm#BRADV89773


     

    Speak Your Mind

    *

    京ICP备14059771号-2