正確答案:D
一、模擬上題的錯誤:
1、刪除4號文件
- [oracle@mydb ~]$ cd /u01/app/oracle/oradata/ocm/
- [oracle@mydb ocm]$ rm -rf users01.dbf
2、數據庫宕機
- sys@OCM> shutdown abort;
- ORACLE instance shut down.
3、啓動數據庫報錯,與上題報錯一樣
- sys@OCM> startup
- ORACLE instance started.
- Total System Global Area 839282688 bytes
- Fixed Size 2233000 bytes
- Variable Size 583011672 bytes
- Database Buffers 247463936 bytes
- Redo Buffers 6574080 bytes
- Database mounted.
- ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
- ORA-01110: data file 4: '/u01/app/oracle/oradata/ocm/users01.dbf'
4、如果試圖在沒有執行advise failure命令時使用repair failure命令,將出現如下錯誤:
- [oracle@mydb ~]$ rman target /
- RMAN> repair failure;
- using target database control file instead of recovery catalog
- RMAN-00571: ===========================================================
- RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
- RMAN-00571: ===========================================================
- RMAN-03002: failure of repair command at 09/01/2013 23:15:16
- RMAN-06954: REPAIR command must be preceded by ADVISE command in same session
主要原因是:在運行repairfailure之前,要先運行advise failure,讓rman列出錯誤,並且生成修復腳本,之後運行repair failure修復錯誤。
一、正確的恢復的過程如下:
1、 啓動RMAN客戶機,並使用前一節介紹的數據庫修復命令來解決丟失數據問題,我們從list failure命令開始:
- RMAN> list failure;
- List of Database Failures
- =========================
- Failure ID Priority Status Time Detected Summary
- ---------- -------- --------- ------------- -------
- 2002 HIGH OPEN 01-SEP-13 One or more non-system datafiles are missing
2、advisefailure命令對記錄在自動診斷信息庫中的所有故障給出建議。默認時,此命令只列出具有critical或high優先級的那些故障。除了產生所有輸入故障的摘要外,此命令還對每個故障提供一個建議修復選項。通常,advise failure命令同時給出自動和手動修復選項。在advisefailure命令輸出結束時,RMAN生成一個腳本,列出建議的修復選項的細節。如果你想自己進行修復,可以直接使用這個腳本,或者對它進行修改。
- RMAN> advise failure;
- List of Database Failures
- =========================
- Failure ID Priority Status Time Detected Summary
- ---------- -------- --------- ------------- -------
- 2002 HIGH OPEN 01-SEP-13 One or more non-system datafiles are missing
- analyzing automatic repair options; this may take some time
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: SID=10 device type=DISK
- analyzing automatic repair options complete
- Mandatory Manual Actions
- ========================
- no manual actions available
- Optional Manual Actions
- =======================
- 1. If file /u01/app/oracle/oradata/ocm/users01.dbf was unintentionally renamed or moved, restore it
- Automated Repair Options
- ========================
- Option Repair Description
- ------ ------------------
- 1 Restore and recover datafile 4
- Strategy: The repair includes complete media recovery with no data loss
- Repair script: /u01/app/oracle/diag/rdbms/ocm/ocm/hm/reco_3275375759.hm
3、利用advise failure命令提供的建議,epair failure根據建議修復錯誤。
- RMAN> repair failure;
- Strategy: The repair includes complete media recovery with no data loss
- Repair script: /u01/app/oracle/diag/rdbms/ocm/ocm/hm/reco_3275375759.hm
- contents of repair script:
- # restore and recover datafile
- restore datafile 4;
- recover datafile 4;
- sql 'alter database datafile 4 online';
- Do you really want to execute the above repair (enter YES or NO)? Y
- executing repair script
- Starting restore at 01-SEP-13
- 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 00004 to /u01/app/oracle/oradata/ocm/users01.dbf
- channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/dbs/0uoiptgq_1_1
- channel ORA_DISK_1: piece handle=/u01/app/oracle/product/11.2.0/dbs/0uoiptgq_1_1 tag=TAG20130901T230250
- channel ORA_DISK_1: restored backup piece 1
- channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
- Finished restore at 01-SEP-13
- Starting recover at 01-SEP-13
- using channel ORA_DISK_1
- starting media recovery
- media recovery complete, elapsed time: 00:00:01
- Finished recover at 01-SEP-13
- sql statement: alter database datafile 4 online
- repair failure complete
- Do you want to open the database (enter YES or NO)? Y
- database opened