DRA(Data Recovery Advisor)的使用
關於DRA的官方描述:
The simplest way to diagnose and repair database problems is to use the Data Recovery Advisor. This Oracle Database tool provides an infrastructure for diagnosing persistent data failures, presenting repair options to the user, and automatically executing repairs.
下面我們來做一個小實驗來實際體會下DRA的便利性:
- rman登入到目標資料庫
- 我們這裡類比丟失了一個資料檔案
- 觀察DRA是如何恢複資料庫的
1.rman登入到目標資料庫
[oracle@JY-DB BACKUP]$ rman target /Recovery Manager: Release 11.2.0.4.0 - Production on Wed Aug 5 11:15:12 2015Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database: JYZHAO (DBID=2463175424, not open)RMAN> LIST FAILURE;using target database control file instead of recovery catalogno failures found that match specification
可以看到目前資料庫沒有找到需要恢複的匹配項。
2.我們這裡類比丟失了一個資料檔案
#2.1 正常關庫SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.#2.2 刪除資料檔案+DATA1/jyzhao/datafile/dbs_d_jingyu.259.886871319#直接刪除資料檔案會報錯ASMCMD> rm DBS_D_JINGYU.259.886871319ORA-15032: not all alterations performedORA-15028: ASM file '+DATA1/jyzhao/datafile/DBS_D_JINGYU.259.886871319' not dropped; currently being accessed (DBD ERROR: OCIStmtExecute)#資料庫關閉後刪除成功ASMCMD> rm DBS_D_JINGYU.259.886871319ASMCMD>#2.3 嘗試開啟資料庫報錯SQL> startupORACLE instance started.Total System Global Area 1620115456 bytesFixed Size 2253704 bytesVariable Size 905972856 bytesDatabase Buffers 704643072 bytesRedo Buffers 7245824 bytesDatabase mounted.ORA-01157: cannot identify/lock data file 15 - see DBWR trace fileORA-01110: data file 15: '+DATA1/jyzhao/datafile/dbs_d_jingyu.259.886871319'
3.觀察DRA是如何恢複資料庫的3.1 LIST FAILURE;
RMAN> LIST FAILURE;List of Database Failures=========================Failure ID Priority Status Time Detected Summary---------- -------- --------- ------------- -------4042 HIGH OPEN 05-AUG-15 One or more non-system datafiles are missing
3.2 ADVISE FAILURE;
RMAN> ADVISE FAILURE;List of Database Failures=========================Failure ID Priority Status Time Detected Summary---------- -------- --------- ------------- -------4042 HIGH OPEN 05-AUG-15 One or more non-system datafiles are missinganalyzing automatic repair options; this may take some timeallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=25 device type=DISKanalyzing automatic repair options completeMandatory Manual Actions========================no manual actions availableOptional Manual Actions=======================1. If file +DATA1/jyzhao/datafile/dbs_d_jingyu.259.886871319 was unintentionally renamed or moved, restore it2. Try flush redo using ALTER SYSTEM FLUSH REDO TO 'standby name' command. Then perform a Data Guard role change (failover). Available standbys: jyzhao_s.Automated Repair Options========================Option Repair Description------ ------------------1 Restore and recover datafile 15 Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/jyzhao/jyzhao/hm/reco_4099084102.hm
3.3 REPAIR FAILURE;
RMAN> REPAIR FAILURE;Strategy: The repair includes complete media recovery with no data lossRepair script: /u01/app/oracle/diag/rdbms/jyzhao/jyzhao/hm/reco_4099084102.hmcontents of repair script: # restore and recover datafile restore datafile 15; recover datafile 15; sql 'alter database datafile 15 online';Do you really want to execute the above repair (enter YES or NO)? yesexecuting repair scriptStarting restore at 05-AUG-15using channel ORA_DISK_1channel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00015 to +DATA1/jyzhao/datafile/dbs_d_jingyu.259.886871319channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/db_1/dbs/arch/JYZHAO/backupset/2015_08_05/o1_mf_nnndf_TAG20150805T102730_bw2x4m1l_.bkpchannel ORA_DISK_1: piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/arch/JYZHAO/backupset/2015_08_05/o1_mf_nnndf_TAG20150805T102730_bw2x4m1l_.bkp tag=TAG20150805T102730channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:01Finished restore at 05-AUG-15Starting recover at 05-AUG-15using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:00Finished recover at 05-AUG-15sql statement: alter database datafile 15 onlinerepair failure completeDo you want to open the database (enter YES or NO)? yesdatabase openedRMAN>
到此,使用DRA自動回復完畢並成功開啟資料庫。