探索Oracle之RMAN_07 重做日志redu文件丢失恢复
重做日志文件记录了数据库的变更数据。一般重做日志文件的失败不会使数据库数据丢失,但是会影响数据库的恢复。重做日志分为两种状态当前联机重做日志和非当前的联机重做日志
4.1 非当前redo(联机重做日志)文件丢失恢复
数据库运行的时候,日志中报如下错误:
ORA-00313: openfailed for members of log group 1 of thread 1
ORA-00312: onlinelog 1 thread 1: '/DBData/WWL/redo01.log'
查看日志组,判断损坏的日志组是否为当前日志组
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ----------------------------- ---------
1 1 32 31457280 1 YES INACTIVE 1063037 04-JUL-12
3 1 34 31457280 1 NO CURRENT 1118555 05-JUL-12
2 1 33 31457280 1 YES INACTIVE 1086278 05-JUL-12
我们可以看到损坏的那组日志不是当前的日志,这个时候我么可以通过使用clear命令来重建该日志文件组。
通过重建来恢复非当前日志组,实现数据库的打开。
SQL> startup
Oracle instancestarted.
Total SystemGlobal Area 100663296 bytes
Fixed Size 1217884 bytes
Variable Size 88083108 bytes
DatabaseBuffers 8388608 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-00313: openfailed for members of log group 1 of thread 1
ORA-00312: onlinelog 1 thread 1: '/DBData/WWL/redo01.log'
SQL>alter database clear logfile group 1;
Databasealtered.
重建完之后数据库可以打开了,至此恢复完成
SQL> alter database open;
Database altered.
4.2当前redo(联机重做日志)文件丢失恢复
数据库启动的时候报如下错误
SQL> startup
ORACLE instance started.
Total System Global Area 100663296 bytes
Fixed Size 1217884 bytes
Variable Size 88083108 bytes
Database Buffers 8388608 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 ofthread 1
ORA-00312: online log 1 thread 1:'/DBData/WWL/redo01.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
查看日志组,判断损坏的日志组是否为当前日志组
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- ------------------- ------------- ---------
1 1 35 31457280 1 NO CURRENT 1139915 05-JUL-12
3 1 34 31457280 1 YES INACTIVE 1118555 05-JUL-12
2 1 33 31457280 1 YES INACTIVE 1086278 05-JUL-12
在这里可以看到损坏的为当前日志组,那么意味着会有在线数据丢失,因为重做日志里面当前状态里面存放的是是没有归档及写入到数据文件的活动数据,那么这种恢复必然是会导致数据的不同步,从而使数据丢失。
我们可以首先尝试清空日志组信息并重建的方式来进行恢复:
SQL> alter database clear unarchived logfile group 1;
alter database clear unarchived logfile group 1
*
ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of instanceWWL (thread 1)
ORA-00312: online log 1 thread 1:'/DBData/WWL/redo01.log'
如上方法不行,可以采取基于SCN,取消的方法来恢复数据库。