SCN不一致将会导致ORA-00600 2662错误

网络整理 - 07-27

在许多情况下,在使用隐含参数_ALLOW_RESETLOGS_CORRUPTION后,用resetlogs打开数据库将会由于SCN不一致出现ORA-00600 2662错误,下文中将针对这一问题的解决过程进行详细的介绍。

首先,在正常启动数据库后,大家可以从alert文件中发现ora-00600 2662号错误。

Sun Dec 11 18:02:25 2005Errors in file /opt/oracle/admin/conner/udump/conner_ora_13349.trc:ORA-00600: internal error code, arguments: [2662], [0], [547743994], [0], [898092653], [8388617], [], []Sun Dec 11 18:02:27 2005Errors in file /opt/oracle/admin/conner/udump/conner_ora_13349.trc:ORA-00600: internal error code, arguments: [2662], [0], [547743994], [0], [898092653], [8388617], [], []Sun Dec 11 18:02:27 2005Error 600 happened during db open, shutting down databaseUSER: terminating instance due to error 600

(可以通过Oracle的内部事件来调整SCN)

增进SCN的常用方法:

1.通过immediate trace name方式(在数据库Open状态下)

alter session set events 'IMMEDIATE trace name ADJUST_SCN level x';

2.通过10015事件(在数据库无法打开,mount状态下)

alter session set events '10015 trace name adjust_scn level x';

注释:level 1为增进SCN 10亿 (1 billion) (1024*1024*1024),一般情况下Level 1已经够用。大家也可以根据实际情况适当调整。

在此示例中由于数据库无法打开,只能使用两种方法。

[oracle@jumper dbs]$ sqlplus "/ as sysdba"SQL*Plus: Release 9.2.0.4.0 - Production on Sun Dec 11 18:26:18 2005Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.Connected to an idle instance.SQL> startup mount pfile=initconner.oraORACLE instance started.Total System Global Area 97588504 bytesFixed Size 451864 bytesVariable Size 33554432 bytesDatabase Buffers 62914560 bytesRedo Buffers 667648 bytesDatabase mounted.SQL> alter session set events '10015 trace name adjust_scn level 10';Session altered.SQL> alter database open;Database altered.

大家需要注意,由于示例中使用了10015事件,使得SCN增进了10 billion,稍后可以继续来验证。

[oracle@jumper dbs]$ sqlplus "/ as sysdba"SQL*Plus: Release 9.2.0.4.0 - Production on Sun Dec 11 18:26:18 2005Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.Connected to an idle instance.SQL> startup mount pfile=initconner.oraORACLE instance started.Total System Global Area 97588504 bytesFixed Size 451864 bytesVariable Size 33554432 bytesDatabase Buffers 62914560 bytesRedo Buffers 667648 bytesDatabase mounted.SQL> alter session set events '10015 trace name adjust_scn level 10';Session altered.SQL> alter database open;Database altered.

此时,数据库可以打开,从alert文件中大家可以发现下面的提示:

Sun Dec 11 18:27:04 2005SMON: enabling cache recoverySun Dec 11 18:27:05 2005Debugging event used to advance scn to 10737418240

SCN被增进了10 billion,即 10 * (1024*1024*1024) = 10737418240,正好是日志里记录的数量。

大家可以从数据库内部看一下检查点的增进情况:

SQL> select open_mode from v$database;OPEN_MODE----------READ WRITESQL> select file#,CHECKPOINT_CHANGE# from v$datafile; FILE# CHECKPOINT_CHANGE#---------- ------------------ 1 547783998 2 547783998 3 547783998SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 97588504 bytesFixed Size 451864 bytesVariable Size 33554432 bytesDatabase Buffers 62914560 bytesRedo Buffers 667648 bytesDatabase mounted.Database opened.SQL> select file#,CHECKPOINT_CHANGE# from v$datafile; FILE# CHECKPOINT_CHANGE#---------- ------------------ 1 1.0737E+10 2 1.0737E+10 3 1.0737E+10SQL> col CHECKPOINT_CHANGE# for 99999999999999999SQL> select file#,CHECKPOINT_CHANGE# from v$datafile; FILE# CHECKPOINT_CHANGE#---------- ------------------ 1 10737418447 2 10737418447 3 10737418447

至此,大家可以发现CHECKPOINT_CHANGE#最后被增进了10 Billion。