zoukankan      html  css  js  c++  java
  • Database Force open example

    帮网友强制打开了一个没有备份的测试库,这个库没有备份也没有打开归档,因为之前也出现过active日志文件损毁,一直使用隐式参数才能正常打开:
                     _allow_resetlogs_corruption= TRUE
    
    这次一开始这个库报ORA-600[2662]错误:
    Mon Aug 23 09:37:00 2010
    Errors in file /oracle/QAS/saptrace/usertrace/qas_ora_852096.trc:
    ORA-00600: internal error code, arguments: [2662], [0], [130131504], [0], [130254136], [4264285], [], []
    Mon Aug 23 09:37:02 2010
    Errors in file /oracle/QAS/saptrace/usertrace/qas_ora_852096.trc:
    ORA-00600: internal error code, arguments: [2662], [0], [130131506], [0], [130254136], [4264285], [], []
    
    ORA-600 [2662] "Block SCN is ahead of Current SCN"错误是当数据块中的SCN领先于current SCN,由于后台进程或服务进程都会比对UGA中的dependent SCN和数据库当前的SCN,如果数据库当前SCN小于dependent SCN,那么该进程就会报ORA-600 [2662]错误,如果遭遇该错误的是服务进程,那么服务进程一般会异常终止;如果遭遇该错误的是后台进程譬如SMON,则会导致实例CRASH。 ORA-600 [2662]错误可以能由以下几种情况引起: 1.启用隐含参数_ALLOW_RESETLOGS_CORRUPTION后,以resetlogs形式打开数据库;这种情况下发生2662错误,根本原因是没有完全前滚导致控制文件中的SCN滞后于数据块中的SCN。 2.硬件故障导致数据库没法写控制文件和联机日志文件 3.错误的部分恢复数据库 4.恢复了控制文件,但是没有使用recover database using backup controlfile进行恢复 5.数据库crash后设置了_DISABLE_LOGGING隐含参数 6.在并行服务器环境中DLM存在问题 该错误的5个参数的具体含义如下: ARGUMENTS: Arg [a] Current SCN WRAP Arg [b] Current SCN BASE Arg [c] dependent SCN WRAP Arg [d] dependent SCN BASE Arg [e] Where present this is the DBA where the dependent SCN came from. 我们的case当中dependent SCN为130254136,而当前SCN为130131506,其差值为122630;从以上告警日志中可以看到数据库的当前SCN是在不断缓慢增长的,当我们遭遇到2662错误时,很滑稽的一点是只要不断重启数据库保持current SCN的增长,一段时间后2662错误会不药而愈。当然我们也可以不用这种笨办法,10015事件可以帮助我们调整数据库当前SCN:
    /* 当数据库处于mount状态,可以使用10015事件来调整scn */
    
    alter session  set events '10015 trace name adjust_scn level 1';
    
    /* 这里可以设置level 2..10等 (level 1是在每次打开数据库时scn增加1000k)*/
    
    /* 需要注意的是10g某些版本不同于9i,需要设置隐式参数_allow_error_simulation,才能真正增进scn */
    
    SQL> select * from v$version;
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    
    SQL> col current_scn format 999,999,999,999
    
    SQL> select current_scn from v$database;
    CURRENT_SCN
    -----------
        1141408
    
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup mount;
    ORACLE instance started.
    
    Total System Global Area 1653518336 bytes
    Fixed Size                  2213896 bytes
    Variable Size             989857784 bytes
    Database Buffers          654311424 bytes
    Redo Buffers                7135232 bytes
    Database mounted.
    
    SQL> alter session set events '10015 trace name adjust_scn level 1';
    Session altered.
    
    SQL> alter database open;
    Database altered.
    
    SQL>  select current_scn from v$database;
    CURRENT_SCN
    -----------
        1142031
    
    /* 可以看到current_scn并未大量增加,10.2.0.4上默认10015 adjust_scn不被触发 */
    
    SQL>  alter system set "_allow_error_simulation"=true scope=spfile;
    System altered.
    
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    
    SQL> startup mount;
    ORACLE instance started.
    Total System Global Area 1653518336 bytes
    Fixed Size                  2213896 bytes
    Variable Size             989857784 bytes
    Database Buffers          654311424 bytes
    Redo Buffers                7135232 bytes
    Database mounted.
    
    SQL> alter session set events '10015 trace name adjust_scn level 1';
    Session altered.
    
    SQL> alter database open;
    Database altered.
    
    SQL>select current_scn from v$database;
         CURRENT_SCN
    ----------------
       1,073,741,980
    
    在接手之前该网友已经通过反复重启数据库将数据库的当前SCN提高到dependent SCN的127037138;原以为这样就可以打开数据库了,谁知道又出现了一下错误:
    Wed Aug 25 07:43:53 2010
    Errors in file /oracle/QAS/saptrace/usertrace/qas_ora_929958.trc:
    ORA-00600: internal error code, arguments: [4000], [8], [], [], [], [], [], []
    Wed Aug 25 07:43:53 2010
    Errors in file /oracle/QAS/saptrace/usertrace/qas_ora_929958.trc:
    ORA-00704: bootstrap process failure
    ORA-00704: bootstrap process failure
    ORA-00600: internal error code, arguments: [4000], [8], [], [], [], [], [], []
    Wed Aug 25 07:43:53 2010
    Error 704 happened during db open, shutting down database
    
    bootstrap自举过程中遭遇了ORA-600 [4000]错误,该错误一般当Oracle尝试读取数据字典(主要是undo$基表)中记录的USN对应的回滚段失败引起.,通过设置隐式参数_corrupted_rollback_segments可以一定程度上规避该错误,强制打开数据库,其Argument[a]代表造成读取失败的USN(undo segment number),但实际上有问题的回滚段可能不止这一个:
    /* 通过strings工具从system表空间上找回各回滚段的名字  */
    $strings system.dbf |grep _SYSSMU|less
    _SYSSMU1$
    _SYSSMU2$
    _SYSSMU3$
    _SYSSMU4$
    _SYSSMU5$
    _SYSSMU6$
    _SYSSMU7$
    _SYSSMU8$
    _SYSSMU9$
    .........
    alter system set "_corrupted_rollback_segments"='(_SYSSMU1$, _SYSSMU2$, _SYSSMU3$, _SYSSMU4$, _SYSSMU5$, _SYSSMU6$, _SYSSMU7$, _SYSSMU8$, _SYSSMU9$, _SYSSMU10$, _SYSSMU11$, _SYSSMU12$)' scope=spfile;
    System altered.
    
    /* 即便设置了_corrupted_rollback_segments隐式参数,也还有一定概率遭遇4000错误,尝试加上10513事件,并多次重启数据库 */
    
    SQL> alter system set event='10513 trace name context forever,level 2' scope=spfile;
    System altered.
    
    /* 再次出现4000 错误 */
    Errors in file /oracle/QAS/saptrace/usertrace/qas_ora_1016014.trc:
    ORA-00600: internal error code, arguments: [4000], [8], [], [], [], [], [], []
    Thu Aug 26 09:43:39 2010
    Errors in file /oracle/QAS/saptrace/usertrace/qas_ora_1016014.trc:
    ORA-00704: bootstrap process failure
    ORA-00704: bootstrap process failure
    ORA-00600: internal error code, arguments: [4000], [8], [], [], [], [], [], []
    Thu Aug 26 09:43:39 2010
    Error 704 happened during db open, shutting down database
    
    /* 再次重启后发现4000错误不再出现 * /
    
    再次重启发现不再出现ORA-600[4000]错误,但在字典检查阶段Oracle认为数据文件227不匹配于当前的incarnation:
    Thu Aug 26 11:13:22 2010
    Dictionary check beginning
    Thu Aug 26 09:46:00 2010
    Errors in file /oracle/QAS/saptrace/usertrace/qas_ora_897162.trc:
    ORA-01177: data file does not match dictionary - probably old incarnation
    ORA-01110: data file 227: '/oracle/QAS/sapdata2/qas_192/qas.data196'
    Error 1177 happened during db open, shutting down database
    USER: terminating instance due to error 1177
    Instance terminated by USER, pid = 897162
    
    初步判断出现ORA-01177可能为2种可能性: 1.数据字典出现讹误,227号文件对应的incarnation信息不正确 2.在之前的某次resetlogs open过程中,227号文件头由于某些原因没有正确更新incarnation信息 针对这样的情况如果一定要找回该数据文件上的数据的话只能通过手动修改数据字典或文件头,当然也可以尝试使用一些直接从数据文件上抽取数据的工具。 因为这是一次友情协助,就没有继续深入下去,通过重建控制文件并跳过该数据文件解决了:
    CREATE CONTROLFILE REUSE DATABASE "QAS" RESETLOGS  NOARCHIVELOG
    --  SET STANDBY TO MAXIMIZE PERFORMANCE
        MAXLOGFILES 255
        MAXLOGMEMBERS 3
        MAXDATAFILES 254
        MAXINSTANCES 50
        MAXLOGHISTORY 36302
    LOGFILE
      GROUP 1 (
        '/oracle/QAS/redolog/redolog11A.dbf',
        '/oracle/QAS/redolog/redolog11B.dbf'
      ) SIZE 500M,
      GROUP 2 (
        '/oracle/QAS/redolog/redolog12A.dbf',
        '/oracle/QAS/redolog/redolog12B.dbf'
      ) SIZE 500M
    -- STANDBY LOGFILE
    DATAFILE
      '/oracle/QAS/sapdata1/system_1/system.data1',
    ........
      '/oracle/QAS/sapdata2/qas_192/qas.data195'
    CHARACTER SET WE8DEC
    Thu Aug 26 14:04:50 2010
    Successful mount of redo thread 1, with mount id 2117500093
    Thu Aug 26 14:04:50 2010
    Completed: CREATE CONTROLFILE REUSE DATABASE "QAS" RESETLOGS
    Thu Aug 26 14:05:05 2010
    alter database mount
    Thu Aug 26 14:05:05 2010
    ORA-1100 signalled during: alter database mount...
    Thu Aug 26 14:05:15 2010
    alter database open resetlogs
    RESETLOGS is being done without consistancy checks. This may result
    in a corrupted database. The database should be recreated.
    RESETLOGS after incomplete recovery UNTIL CHANGE 1125281471596
    Resetting resetlogs activation ID 0 (0x0)
    Online log 1 of thread 1 was previously cleared
    Thu Aug 26 14:05:36 2010
    Assigning activation ID 2117500093 (0x7e367cbd)
    Thread 1 opened at log sequence 1
      Current log# 2 seq# 1 mem# 0: /oracle/QAS/redolog/redolog12A.dbf
      Current log# 2 seq# 1 mem# 1: /oracle/QAS/redolog/redolog12B.dbf
    Successful open of redo thread 1
    Thu Aug 26 14:05:36 2010
    SMON: enabling cache recovery
    Thu Aug 26 14:05:36 2010
    Dictionary check beginning
    Tablespace 'PSAPTEMP' #2 found in data dictionary,
    but not in the controlfile. Adding to controlfile.
    File #227 found in data dictionary but not in controlfile.
    Creating OFFLINE file 'MISSING00227' in the controlfile.
    This file can no longer be recovered so it must be dropped.
    File #228 found in data dictionary but not in controlfile.
    Creating OFFLINE file 'MISSING00228' in the controlfile.
    This file can no longer be recovered so it must be dropped.
    File #229 found in data dictionary but not in controlfile.
    Creating OFFLINE file 'MISSING00229' in the controlfile.
    This file can no longer be recovered so it must be dropped.
    Dictionary check complete
    Thu Aug 26 14:05:38 2010
    SMON: enabling tx recovery
    Thu Aug 26 14:05:38 2010
    Database Characterset is WE8DEC
    replication_dependency_tracking turned off (no async multimaster replication found)
    Completed: alter database open resetlogs
    

    这个case告诉我们,测试库并不一定就不重要,测试库也是需要备份的。

  • 相关阅读:
    Rocket
    Rocket
    Rocket
    Rocket
    POJ 1849 树的直径 Two
    SGU 495 Kids and Prizes
    HDU 4336 概率DP 状压
    HDU 4089 && UVa 1498 Activation 带环的概率DP
    SGU 149 树形DP Computer Network
    暑假集训刷题记录
  • 原文地址:https://www.cnblogs.com/macleanoracle/p/2967517.html
Copyright © 2011-2022 走看看