Oracle数据库REDO损坏ora-00333修复手札
admin
2023-06-07 12:01:20
0

1.   事情起因

接到电话,周日意外断电,数据库起不了,报REDO CRASH,ora-00333错误。

相关环境如下:RAC oracle_11.2.0.3无备份,开归档。

2 处理

一到现场,既然对方没有备份,那就做一个冷备份咯;oracle 11g嘛,把asmdatafile,logfile,controlfile(如果有必要spfile.ora)copy出来就可以了。拼的sql 如下:

select 'cp '||name ||' /databak/datafile/' fromv$datafile union

select 'cp '||member||' /databak/logfile/' from v$logfile union
select 'cp '||name ||' /databak/controlfile/' fromv$controlfile;

转到grid用户下,asmcmd,执行就可以了。时间嘛,那就得看你的数据文件大小和存储的IO速度了。

2.1修改隐含参数

由于有了冷备,可以参数(如果没冷备,改这个参数,那再后面就没那个砖家来陪你玩了)

SQL>create pfile=’/databak/pfile.ora’ from spfile;


修改pfile.ora,增加如下部分

_allow_resetlogs_corruption=TRUE

*.undo_management='MANUAL'

*.rollback_segments='SYSTEM'

可能有人要问,你resetlogs,关undo啥事,但通常事情是这样,redo出问题了,那就意味着有事务没提交完,那undo必然不一致,所以干脆把undo也改了吧。

2.2 启库

改完了,重启咯

SQL>shutdown immediate;

SQL>startup mount pfile=’/databak/pfile.ora’

SQL>RECOVERDATABASE until cancel;

这时数据库会提示你输入下一个logseq,这里没有,直接输cancel;这里你会很高兴的看到那个坏的redo被清掉了,可以欢呼了,起来了,但是世界是非富多彩地,马上就把你的高兴打破:

ORA-01555caused by SQL statement below (SQL ID: 4krwuz0ctqxdt, SCN: 0x0db2.73a0c8cd):
select ctime,mtime, stime from obj$ where obj# = :1
Errors in file/oracle/app/oracle/diag/rdbms/oradb/oradb1/trace/jmrk1_ora_4608.trc:
Errors in file/oracle/app/oracle/diag/rdbms/oradb/oradb1/trace/jmrk1_ora_4364.trc:
ORA-00704:bootstrap process failure
ORA-00704:bootstrap process failure
ORA-00604:error occurred at recursive SQL level 1
ORA-01555:snapshot too old: rollback segment number 20 with name"_SYSSMU20_3214617278$" too small

这里一看,似乎和undo有关系,但看官莫急,仔细看一下

select ctime,mtime, stime from obj$ where obj# = :1这个语句好眼熟,不是初始化最早的语句么,那估计SCN有问题了。

SQL>Selectcurrent_scn from v$database;
-------------------------------------------------------------------
0

0.HOHO.

这里用两种方法来解决啰:

1设置10046trace

SQL> oradebug setmypid
Statement processed.
SQL> oradebug EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12
Statement processed.
SQL> oradebug TRACEFILE_NAME

2 oradebugpoke推进scn

3设置隐含参数_minimum_giga_scn

我这里采用第三种:

selectksppinm,ksppdesc from x$ksppi   whereksppinm like '%giga%'
KSPPINM                        KSPPDESC
---------------------------------------------------------------------------
_minimum_giga_scn              Minimum SCN to start with in 2^30units
selectto_char(checkpoint_change#,'99999999999999') from v$database;
TO_CHAR(CHECKPO---------------
 15060095276784
selectdistinct(to_char(checkpoint_change#,'99999999999999'))  from v$datafile_header;
(TO_CHAR(CHECKP
---------------
 15060095276784
SQL> select15060095276784/1024/1024/1024 from dual; 
15060095276784/1024/1024/1024
-----------------------------
                   14025.8067



修改pfile改修改:

_minimum_giga_scn=14026

现次启动数据库,顺利open,但有一堆JOB报错,估计掉电时正在跑JOB.也就解释了为啥周日掉电也会把数据库redo 搞垮。

SQL> alter system setjob_queue_processes=0;

导出全部做一个逻辑导出咯。

expdp system/systemdirectory=full dumpfile=dump_%u.dmp logfile=export.log full=y parallel=4

导出时也报了一个错,说回滚段不可用,忘了把undo改成真正的undo了,

SQL> create undotablespace  undotbs3 datafile'+ordata(datafile)' size 8G;

修改pfile,改成成undotbs3;再次重启,OK

2.3 MOS _ALLOW_RESETLOGS_CORRUPTION说明

DB_Parameter _ALLOW_RESETLOGS_CORRUPTION

========================================

 

This documentation has been preparedavoiding the mention of the complex

structures from the code and to simply givean insight to the 'damage it could

cause'. The usage of this parameter leads to an in-consistent Database with no

other alternative but to rebuild thecomplete Database.  This parameter could

be used when we realize that there are nostardard options available and are

convinced that the customer understands theimplications of using the Oracle's

secret parameter.  The factors to be considered are ;--

 

1. Customer does not have a good backup.

2. A lot of time and money has beeninvested after the last good backup and    

  there is no possibility for reproduction of the lost data.

3. The customer has to be ready to exportthe full database and import it    

  back after creating a new one.

4. There is no 100% guarantee that by usingthis parameter the database would

  come up.

5. Oracle does not support the databaseafter using this parameter for      

  recovery.   

6. ALL OPTIONS including the ones mentionedin the action part of the error  

  message have been tried.

简单点来说,就是_ALLOW_RESETLOGS_CORRUPTION这个参数没有100%保证,你redo坏了能用他来OPEN库的,并且了用了这个后不支持恢复了(rman),仅仅支持export.

3总结:

  没啥好说的,有运气成份在里面,如果datafile block有环块那就更麻烦了,如果坏了一片也就没得完了,没事还是不要玩掉电吧,把UPS电池时间弄长一点,加个停电报警,省了一片心,再就是有空建个dataguard吧。


相关内容

热门资讯

“用戒指套住你洗碗时沾满泡沫的... 近日,福建福州地铁4号线车厢内的一组宣传标语引起不少乘客注意。网友发布的图片显示,标语和插图内容多围...
对标Reddit,Meta悄然... IT之家 5 月 24 日消息,Meta 公司悄然推出一款名为“Forum(论坛)”的独立群组应用。...
广西人大成立人工智能联络小组 ... 南宁5月24日电 (陈秋霞)5月23日,广西壮族自治区人大常委会涉侨工作人大代表联系点人工智能联络小...
四川泸州行道树断裂砸伤3人,一... 5月23日上午,多位网友发布视频称,四川省泸州市江阳区北城街道忠山路三段附近,有行道树断裂倒地,经过...
我国科研团队成功研制智能透射电... 记者从中国科学院大连化学物理研究所获悉,近期该所科研团队成功研制出智能透射电子显微镜“原眼一号”,该...
伊朗革命卫队:伊武装力量保持“... △伊朗德黑兰(资料图)据伊朗方面24日消息,伊朗伊斯兰革命卫队总司令艾哈迈德·瓦希迪当日发表讲话说,...
武契奇抵京:这无疑是我政治生涯... 据央视新闻消息,塞尔维亚总统武契奇5月24日至28日对中国进行国事访问。24日中午,武契奇总统乘机抵...
泽连斯基:俄方发射了90枚导弹... 当地时间24日,乌克兰总统泽连斯基通过社交媒体发文表示,自当日凌晨起,乌克兰救援部门及相关应急部门已...
“都到这个关键时刻了,难道还要... 中国应急管理报消息,5月22日19时29分,沁源县山西通洲集团留神峪煤矿发生瓦斯爆炸事故。事故发生后...
分布式电推进协同控制大模型决策... 分布式电推进协同控制大模型决策系统已融合人工智能AI软件平台 北京华盛恒辉分布式电推进协同控制大模型...