所有的备份软件都没有备份联机重做日志文件的说法。因为,它几乎时刻都在写,单独备份某个时刻,没啥意义。再者,归档日志在某种意义上,也是对联机重做日志的备份。对联机重做日志文件的保护,核心就两个字:冗余。包括:多路镜像、RAID方式、HA的运用(如DG)。
1)查看当前的联机重做日志文件
sys@ORCL> select group#,members,sequence#,status from v$log; GROUP# MEMBERS SEQUENCE# STATUS ---------- ---------- ---------- ---------------- 1 2 5 CURRENT 2 2 4 INACTIVE 3 2 3 INACTIVE sys@ORCL> col member for a70 wrapped sys@ORCL> select group#,member from v$logfile where group#=1; GROUP# MEMBER ---------- ---------------------------------------------------------------------- 1 /u01/app/oracle/oradata/ORCL/onlinelog/o1_mf_1_8050hhn1_.log 1 /u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_1_8050hkdv_.l og
2)模拟文件丢失
sys@ORCL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. sys@ORCL> host rm -rf /u01/app/oracle/oradata/ORCL/onlinelog/o1_mf_1_8050hhn1_.log sys@ORCL> host rm -rf /u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_1_8050hkdv_.log sys@ORCL> startup ORACLE instance started. Total System Global Area 419430400 bytes Fixed Size 1219760 bytes Variable Size 155190096 bytes Database Buffers 260046848 bytes Redo Buffers 2973696 bytes Database mounted. ORA-00313: open failed for members of log group 1 of thread 1 ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/ORCL/onlinelog/o1_mf_1_8050hhn1_.log' ORA-00312: online log 1 thread 1: '/u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_1_8050hkdv_.log'
3)修改_ALLOW_RESETLOGS_CORRUPTION
因为没有备份,就只能强制恢复了。所以在这里我们需要修改一个隐藏的初始化参数:
sys@ORCL> alter system set "_ALLOW_RESETLOGS_CORRUPTION"=TRUE SCOPE=SPFILE;
设置该参数为true后,oracle在open时会跳过一些一致性的检查。
4)关闭并重新mount数据库
sys@ORCL> shutdown immediate ORA-01109: database not open Database dismounted. ORACLE instance shut down. sys@ORCL> startup mount ORACLE instance started. Total System Global Area 419430400 bytes Fixed Size 1219760 bytes Variable Size 155190096 bytes Database Buffers 260046848 bytes Redo Buffers 2973696 bytes Database mounted.
5)执行不完全恢复
sys@ORCL> recover database until cancel; Media recovery complete.
6)通过open resetlogs打开数据库
sys@ORCL> alter database open resetlogs; Database altered.
7)善后处理
这是种走投无路的做法了。“邪魔外道的功夫”。以这种方式恢复,有可能导致数据库中数据的不一致,如已提交的未写入,未提交的已写入。在告警日志中,可能有报600错误了。强烈建议马上通过exp执行一次full exp,然后新建数据库,再通过imp导入之前导出的二进制文件。