現象:業務平台無法登陸,日志報錯為ORACLE的錯誤。
查看oracle日志的報錯,
ORA-00376: file 5 cannot be read at this time ORA-01110: data file 5: '/oradata/users02.dbf'
看一下oracle狀態,
SQL> select status from v$instance; STATUS ------------ OPEN
奇怪了,數據庫狀態正常,還報錯,應該是數據文件有問題,查一下數據文件的SCN,發現確實是datafile 5有問題,其SCN與其他的不一致。
接下來開始要恢復了。嘗試恢復數據文件5,
SQL> recovere datafile 5; SP2-0734: unknown command beginning "recovere d..." - rest of line ignored. SQL> recover datafile 5; ORA-00279: change 14945741822997 generated at 03/22/2018 22:13:55 needed for thread 1 ORA-00289: suggestion : /usr/local/oracle/flash_recovery_area/ORCL/archivelog/2018_03_26/o1_mf_1_298748_ %u_.arc ORA-00280: change 14945741822997 for thread 1 is in sequence #298748 Specify log: {<RET>=suggested | filename | AUTO | CANCEL} redo03.log; ORA-00308: cannot open archived log 'redo03.log;' ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3
加上until cancle參數再次嘗試恢復,恢復數據原則要進程不斷嘗試
SQL> recover datafile 5 until cancel; ORA-00274: illegal recovery option UNTIL
嘗試將數據文件5 online,
SQL> alter database datafile 5 online; alter database datafile 5 online * ERROR at line 1: ORA-01113: file 5 needs media recovery ORA-01110: data file 5: '/oradata/users02.dbf'
這里報錯,應該是數據庫已經OPEN了,無法進行數據文件恢復。將數據庫關閉,啟動至mount狀態,
SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount; ORACLE instance started. Total System Global Area 6747725824 bytes Fixed Size 2213976 bytes Variable Size 4160751528 bytes Database Buffers 2550136832 bytes Redo Buffers 34623488 bytes Database mounted.
再次加上until cancle參數再次嘗試恢復,
SQL> recover database until cancel; Media recovery complete.
打開數據庫,完成介質恢復,
SQL> alter database open; alter database open * ERROR at line 1: ORA-01589: must use RESETLOGS or NORESETLOGS option for database open SQL> alter database open RESETLOGS; Database altered. SQL> select status from v$instance; STATUS ------------ OPEN
這時,介質恢復應該就完成了,再去查一下SCN,
SQL> select checkpoint_change# from v$datafile; CHECKPOINT_CHANGE# ------------------ 1.4946E+13 1.4946E+13 1.4946E+13 1.4946E+13 1.4946E+13 1.4946E+13 1.4946E+13 1.4946E+13 1.4946E+13 1.4946E+13 1.4946E+13 CHECKPOINT_CHANGE# ------------------ 1.4946E+13 1.4946E+13 1.4946E+13 14 rows selected. SQL>
一致了,驗證一下業務平台,正常了。