阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Oracle Hidden Parameter:_allow_resetlogs_corruption

219次阅读
没有评论

共计 3294 个字符,预计需要花费 9 分钟才能阅读完成。

提示:Oracle 的隐含参数只应该在测试环境或者在 Oracle Support 的支持下使用。
在使用_disable_logging 进一步的测试中,试图通过 switch logfile 进行日志切换,结果重起居然报出日志文件损坏。

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 count(*) from t;
select count(*) from t
                     *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> create table t as select * from dba_users;

Table created.

SQL> select count(*) from t;

  COUNT(*)
----------
        12

试图通过 switch logfile 触发检查点:

SQL> alter system switch logfile;

System altered.


SQL> insert into t select * from t;

12 rows created.

SQL> commit;

Commit complete.

SQL> select count(*) from t;

  COUNT(*)
----------
        24

日志文件损坏 (未测试是否可以重复出现):

SQL> startup force;
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.
ORA-00354: corrupt redo log block header
ORA-00353: log corruption near block 3 change 897612314 time 10/19/2005 14:19:34
ORA-00312: online log 3 thread 1: '/opt/oracle/oradata/conner/redo03.log'

损坏的是 active 的日志文件:

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1        159   10485760          1 NO  INACTIVE             897592312 19-OCT-05
         2          1        158   10485760          1 NO  INACTIVE             897572310 19-OCT-05
         3          1        160   10485760          1 NO  ACTIVE               897612314 19-OCT-05
         4          1        161    1048576          1 NO  CURRENT              897612440 19-OCT-05

只好使用另外一个隐含参数_allow_resetlogs_corruption 强制启动数据库,设置此参数之后,在数据库 Open 过程中,Oracle 会跳过某些一致性检查,从而使数据库可能跳过不一致状态,Open 打开:

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

System altered.

SQL> shutdown immediate;
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
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> recover database using backup controlfile until cancel;
ORA-00279: change 897612315 generated at 10/19/2005 16:54:18 needed for thread 1
ORA-00289: suggestion : /opt/oracle/oradata/conner/archive/1_160.dbf
ORA-00280: change 897612315 for thread 1 is in sequence #160


Specify log: {=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: '/opt/oracle/oradata/conner/system01.dbf'


ORA-01112: media recovery not started


SQL> alter database open resetlogs;

Database altered.

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.

幸运的时候数据库就可以成功 Open,如果不幸可能会遇到一系列的 ORA-600 错误(最常见的是 2662 错误)此时就需要使用多种手段继续进行调整恢复。
如果注意观察 alert 日志,我们可能会发现类似以下日志:

Fri Jun 10 16:30:25 2005
alter database open resetlogs
Fri Jun 10 16:30:25 2005
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 240677200
Resetting resetlogs activation ID 3171937922 (0xbd0fee82)

Oracle 告诉我们,强制 resetlogs 跳过了一致性检查,可能导致数据库损坏,数据库应当重建。
不一致恢复最后恢复到的 Change 号是:240677200

通常使用此方法 Open 数据库之后,应该立即通过导出、导入重建数据库。

更多 Oracle 相关信息见 Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-02/141076.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计3294字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中