当前日志文件全部损坏和丢失的恢复

当前全部日志文件丢失有二种情况,一是数据库在关闭状态,数据是一致的,这时可以通过

alter database clear logfile group 1

重建日志文件,然后

alter dtatbase open resetlogs

打开数据库,然后做全库备份

二是数据库在打开状态,Oracle例程会中止


      一是通过有效全备份执行不完全恢复,

     Rovcover database until cancel,这样可能会有数据的丢失。

 

如果没有有效全备份

 

SQL> alter database open resetlogs;
alter database open resetlogs
*
第 1 行出现错误:
ORA-01194: 文件 1 需要更多的恢复来保持一致性
ORA-01110: 数据文件 1: 'D:\ORACLE\PRODUCT\10.1.0\ORADATA\MYORACLE\SYSTEM01.DBF'

 

数据不一致,无法打开!
通过隐含参数_allow_resetlogs_corruption=TRUE强制打开

Ex;

 

SQL> alter system set  "_allow_resetlogs_corruption"=true scope=spfile;

系统已更改。

SQL> shutdown immediate;
ORA-01109: 数据库未打开


已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup
ORACLE 例程已经启动。

Total System Global Area  524288000 bytes
Fixed Size                   789692 bytes
Variable Size             497808196 bytes
Database Buffers           25165824 bytes
Redo Buffers                 524288 bytes
数据库装载完毕。
ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项


SQL> alter database open resetlogs;
alter database open resetlogs
*
第 1 行出现错误:
ORA-03113: 通信通道的文件结束

遭遇ORA-00600: 内部错误代码, 参数: [2662]错误

 

 

MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Thu Jun 10 11:43:44 2010
SMON: enabling cache recovery
Thu Jun 10 11:43:45 2010
Errors in file d:\oracle\product\10.1.0\admin\myoracle\udump\myoracle_ora_90368.trc:
ORA-00600: 内部错误代码, 参数: [2662], [0], [52373651], [0], [52377759], [29360137], [], []

Thu Jun 10 11:43:48 2010
Errors in file d:\oracle\product\10.1.0\admin\myoracle\udump\myoracle_ora_90368.trc:
ORA-00600: 内部错误代码, 参数: [2662], [0], [52373651], [0], [52377759], [29360137], [], []

Thu Jun 10 11:43:48 2010
Error 600 happened during db open, shutting down database
USER: terminating instance due to error 600
Thu Jun 10 11:43:48 2010
Errors in file d:\oracle\product\10.1.0\admin\myoracle\bdump\myoracle_pmon_88840.trc:
ORA-00600: internal error code, arguments: [], [], [], [], [], [], [], []

 

在数据库Open过程中,Oracle会跳过某些一致性检查,从而使数据库可能跳过不一致状态,Open打开,如果不幸运的话会得到如上的错误

 

作者:eygle | English Version 【转载时请以超链接形式标明文章出处和作者信息及本声明

 

ORA-00600 2662号错误,这个错误的含义是:

data block SCN is ahead of the current SCN.
The ORA-600 [2662] occurs when an SCN is compared to the dependent SCN
stored in a UGA variable.
If the SCN is less than the dependent SCN then we signal the ORA-600 [2662]
internal error.
在测试中,很容易模拟这个错误:

Thu Oct 20 10:38:27 2005
            SMON: enabling cache recovery
            Thu Oct 20 10:38:27 2005
            Errors in file /opt/oracle/admin/conner/udump/conner_ora_31607.trc:
            ORA-00600: internal error code, arguments: [2662], [0], [897694446], [0], [897695488], [8388697], [], []
            Thu Oct 20 10:38:28 2005
            Errors in file /opt/oracle/admin/conner/udump/conner_ora_31607.trc:
            ORA-00600: internal error code, arguments: [2662], [0], [897694446], [0], [897695488], [8388697], [], []
            

 


如果SCN相差不多,可以通过多次重起数据库解决。

在ORA-00600很多时候使用隐含参数_ALLOW_RESETLOGS_CORRUPTION后resetlogs打开数据库,我们可能会由于SCN不一致而遭遇到ORA-00600 2662号错误,这里给出一个完整的例子及解决过程。

当然模拟2662错误需要技巧,本文并不会涉及这个内容。

通过正常方式启动数据库时,从alert文件中,我们可以看到ora-00600 2662号错误。

Sun Dec 11 18:02:25 2005
Errors 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 2005
Errors 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 2005
Error 600 happened during db open, shutting down database
USER: 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 2005
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
Connected to an idle instance.
SQL> startup mount pfile=initconner.ora
ORACLE instance started.
Total System Global Area   97588504 bytes
Fixed Size                   451864 bytes
Variable Size              33554432 bytes
Database Buffers           62914560 bytes
Redo Buffers                 667648 bytes
Database 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 2005
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
Connected to an idle instance.
SQL> startup mount pfile=initconner.ora
ORACLE instance started.
Total System Global Area   97588504 bytes
Fixed Size                   451864 bytes
Variable Size              33554432 bytes
Database Buffers           62914560 bytes
Redo Buffers                 667648 bytes
Database 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 2005
SMON: enabling cache recovery
Sun Dec 11 18:27:05 2005
Debugging 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 WRITE
SQL> select file#,CHECKPOINT_CHANGE# from v$datafile;
     FILE# CHECKPOINT_CHANGE#
---------- ------------------
                 547783998
                 547783998
                 547783998
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area   97588504 bytes
Fixed Size                   451864 bytes
Variable Size              33554432 bytes
Database Buffers           62914560 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.
SQL> select file#,CHECKPOINT_CHANGE# from v$datafile;
     FILE# CHECKPOINT_CHANGE#
---------- ------------------
                1.0737E+10
                1.0737E+10
                1.0737E+10
SQL> col CHECKPOINT_CHANGE# for 99999999999999999
SQL>  select file#,CHECKPOINT_CHANGE# from v$datafile;
     FILE# CHECKPOINT_CHANGE#
---------- ------------------
               10737418447
               10737418447
               10737418447

 已连接到空闲例程。
SQL> startup mount
ORACLE 例程已经启动。

Total System Global Area  524288000 bytes
Fixed Size                   789692 bytes
Variable Size             497808196 bytes
Database Buffers           25165824 bytes
Redo Buffers                 524288 bytes
数据库装载完毕。
SQL> alter session set events '10015 trace name adjust_scn level 1';

会话已更改。

SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01092: ORACLE 例程终止。强制断开连接
*** 2010-06-10 14:28:05.865
ksedmp: internal or fatal error

Alertlog:


Block recovery completed at rba 6.70.16, scn 0.52475297
Thu Jun 10 14:28:13 2010
Errors in file d:\oracle\product\10.1.0\admin\myoracle\udump\myoracle_ora_100896.trc:
ORA-00607: 当更改数据块时出现内部错误
ORA-00600: 内部错误代码, 参数: [4194], [44], [6], [], [], [], [], []

Error 607 happened during db open, shutting down database
USER: terminating instance due to error 607
Thu Jun 10 14:28:13 2010
Errors in file d:\oracle\product\10.1.0\admin\myoracle\bdump\myoracle_reco_100760.trc:
ORA-00607: Internal error occurred while making a change to a data block

Ttrace文件中:

ORA-00600: 内部错误代码, 参数: [4194], [44], [6], [], [], [], [], []
Current SQL statement for this session:
Current SQL statement for this session:
update service$ set name = :1, name_hash = :2, network_name = :3, creation_date = :4, creation_date_hash = :5, deletion_date = null where service_id = :6 and deletion_date is null

--增加SCN,重启几次也无法打开数据库,继续

--应该是UNDO出问题了,现在无法打开数据库,所以不能重建UNDO 表空间

--http://dev.csdn.net/htmls/83/83637.html借鉴一下

 

--把UNDO的管理改为手动管理

 SQL> connect / as sysdba;
已连接到空闲例程。
SQL> startup mount
ORACLE 例程已经启动。

Total System Global Area  524288000 bytes
Fixed Size                   789692 bytes
Variable Size             497808196 bytes
Database Buffers           25165824 bytes
Redo Buffers                 524288 bytes
数据库装载完毕。
SQL> alter system set undo_management=manual scope=spfile;

系统已更改。

SQL> show parameter undo

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      AUTO
undo_retention                       integer     900
undo_tablespace                      string      JERRY_UNDO
SQL> shutdown immediate;
ORA-01109: 数据库未打开


已经卸载数据库。
ORACLE 例程已经关闭。

SQL> startup mount
ORACLE 例程已经启动。

Total System Global Area  524288000 bytes
Fixed Size                   789692 bytes
Variable Size             497808196 bytes
Database Buffers           25165824 bytes
Redo Buffers                 524288 bytes
数据库装载完毕。
SQL> show parameter undo

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      MANUAL
undo_retention                       integer     900
undo_tablespace                      string      JERRY_UNDO
SQL> recover database until cancel;
ORA-00279: 更改 52556015 (在 06/11/2010 09:36:34 生成) 对于线程 1 是必需的
ORA-00289: 建议:
D:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\MYORACLE\ARCHIVELOG\2010_06_11\O1_M

F_1_1_%U_.ARC
ORA-00280: 更改 52556015 (用于线程 1) 在序列 #1 中


指定日志: {<RET>=suggested | filename | AUTO | CANCEL}

ORA-00308: 无法打开归档日志
'D:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\MYORACLE\ARCHIVELOG\2010_06_11\O1_

MF_1_1_%U_.ARC'
ORA-27041: 无法打开文件
OSD-04002: 无法打开文件
O/S-Error: (OS 2) 系统找不到指定的文件。


ORA-01547: 警告: RECOVER 成功但 OPEN RESETLOGS 将出现如下错误
ORA-01194: 文件 1 需要更多的恢复来保持一致性
ORA-01110: 数据文件 1: 'D:\ORACLE\PRODUCT\10.1.0\ORADATA\MYORACLE\SYSTEM01.DBF'


SQL> alter database open resetlogs;

数据库已更改。

---终于打开数据库了

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值