本文主要是介绍[Oracle] Active或Current联机日志文件丢失如何恢复?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
联机日志文件状态为active或current表示该日志包含的数据修改还未完全同步到数据文件中,在实例恢复时,还需要读取其中的redo记录重演,因此如果损坏,数据丢失在所难免。1)模拟灾难
首先查看log的状态:
SQL> select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
2 5 CURRENT
3 3 INACTIVE
4 4 INACTIVE
Group#2的状态为current,我们找出它所对应的磁盘文件为:
SQL> select group#,member from v$logfile where group#=2;
GROUP# MEMBER
---------- ---------------------------------------------------------
2 J:\INTEL_LOG\O04DMS0\REDO02.O04DMS0
如果数据库时正常关闭,在关闭之前,会做一次数据文件同步,因此为了模拟current文件丢失的情况,我们异常关闭数据库:
SQL> shutdown abort;
然后把Group#2对应的文件REDO02.O04DMS0在操作系统级别上删除。
2)根据错误信息定位问题
启动数据库会出现以下错误
SQL> startup
ORACLE instance started.
Total System Global Area 281018368 bytes
Fixed Size 1296292 bytes
Variable Size 251660380 bytes
Database Buffers 25165824 bytes
Redo Buffers 2895872 bytes
Database mounted.
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: 'J:\INTEL_LOG\O04DMS0\REDO02.O04DMS0'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.
由于有一组日志文件丢失,因此数据库只能mount,无法open,查看一下丢失的日志文件是什么状态:
SQL> select group#,sequence#,status from v$log where group#=2;
GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
2 5CURRENT
非常不幸,丢失的日志文件时current状态,也就是说数据丢失时难免的,现在能问题是如何让数据库能正常打开。
这时候得修改一个隐藏参数_allow_resetlogs_corruption为true,这个参数为true表示” resetlogs forced to skip the consistency check“:
SQL> alter system set "_allow_resetlogs_corruption"=true scope=spfile;
修改之后重启让其生效,接着做一次不完全恢复:
SQL> recover database until cancel;
ORA-00279: change 30656042 generated at 11/20/2011 05:32:01 needed for thread 1
ORA-00289: suggestion : H:\INTEL_ARCH\O04DMS0\O04DMS0_1_5_767679611.ARCH
ORA-00280: change 30656042 for thread 1 is in sequence #5
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: 'I:\INTEL_DATA\O04DMS0\SYSTEM01.O04DMS0'
ORA-01112: media recovery not started
选择cancel,出现ORA-错误没关系,这是预料之中的,接着以resetlogs方式打开数据库:
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
这时还是错误,可能是上面出现的ORA_03113,也可能是ORA-600错误,没关系,这都是在预料之中,最后重启一下就可以了。
此时REDO02.O04DMS0文件在操作系统级别上已经恢复回来了,在数据库中的状态如下:
SQL> select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
2 1 INACTIVE
3 2 CURRENT
4 0 UNUSED
这篇关于[Oracle] Active或Current联机日志文件丢失如何恢复?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!