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
更多精彩文章,請訪問作者個人博客:www.dbstyle.net