分享更有价值
被信任是一种快乐

BBED丢失归档文件情况下的恢复方法

文章页正文上

BBED丢失归档文件情况下的恢复方法,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。 【BBED】丢失归档文件情况下的数据文件的恢复 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~:① 若丢失归档情况下数据文件的恢复,bbed和隐含参数(重点)② 数据库启动过程中的介质恢复,scn号的关系③ BBED如何修改文件头④ 归档和非归档模式下数据库的全备 Tips: ① 若文章代码格式有错乱,推荐使用QQ、搜狗或360浏览器,也可以下载pdf格式的文档来查看,pdf文档下载地址:http://yunpan.cn/cdEQedhCs2kFz(提取码:ed9b) ② 本篇BLOG中命令的输出部分需要特别关注的地方我都用灰色背景和粉红色字体来表示,比如下边的例子中,thread 1的最大归档日志号为33,thread 2的最大归档日志号为43是需要特别关注的地方;而命令一般使用黄色背景和红色字体标注;对代码或代码输出部分的注释一般采用蓝色字体表示。 List of Archived Logs in backup set 11 Thrd Seq Low SCN Low Time Next SCN Next Time —- ——- ———- ——————- ———- ——— 1 32 1621589 2015-05-29 11:09:52 1625242 2015-05-29 11:15:48 1 33 1625242 2015-05-29 11:15:48 1625293 2015-05-29 11:15:58 2 42 1613951 2015-05-29 10:41:18 1625245 2015-05-29 11:15:49 2 43 1625245 2015-05-29 11:15:49 1625253 2015-05-29 11:15:53[ZFXXDB1:root]:/>lsvg -oT_XDESK_APP1_vgrootvg[ZFXXDB1:root]:/>00:27:22 SQL> alter tablespace idxtbs read write;====》2097152*512/1024/1024/1024=1G本文如有错误或不完善的地方请大家多多指正,ITPUB留言或QQ皆可,您的批评指正是我写作的最大动力。 ORACLE 11g TSPITR恢复被删除的表空间http://blog.itpub.net/26736162/viewspace-1681706/【RMAN】RMAN脚本中使用替换变量–windows 下rman全备脚本http://blog.itpub.net/26736162/viewspace-1673725/【TSPITR】RMAN表空间基于时间点的自动恢复http://blog.itpub.net/26736162/viewspace-1671741/【推荐】 【RMAN】rm -rf 误操作的恢复过程http://blog.itpub.net/26736162/viewspace-1623938/【推荐】 【RMAN】利用备份片还原数据库(中)-附加http://blog.itpub.net/26736162/viewspace-1621938/【推荐】 【RMAN】利用备份片还原数据库(下)http://blog.itpub.net/26736162/viewspace-1621672/【推荐】 【RMAN】利用备份片还原数据库(中)http://blog.itpub.net/26736162/viewspace-1621661/【推荐】 【RMAN】利用备份片还原数据库(上)http://blog.itpub.net/26736162/viewspace-1621581/【推荐】 【RMAN】RMAN跨版本恢复(下)http://blog.itpub.net/26736162/viewspace-1562583/【推荐】 Oracle 组件 系列 小结http://blog.itpub.net/26736162/viewspace-1562441/【推荐】 【RMAN】RMAN跨版本恢复(中)http://blog.itpub.net/26736162/viewspace-1561352/【推荐】 【RMAN】RMAN跨版本恢复(上)http://blog.itpub.net/26736162/viewspace-1561185/【推荐】 关于在不同版本和平台之间进行还原或复制的常见问题http://blog.itpub.net/26736162/viewspace-1549041/【推荐】 undo表空间文件丢失恢复(4)–无备份无recover的情况下恢复http://blog.itpub.net/26736162/viewspace-1458787/【推荐】 undo表空间文件丢失恢复(3)–无备份无redo的情况下恢复http://blog.itpub.net/26736162/viewspace-1458750/【推荐】 undo表空间文件丢失恢复(2)–无备份有redo的情况下恢复http://blog.itpub.net/26736162/viewspace-1458663/【推荐】 undo表空间文件丢失恢复(1)–有备份http://blog.itpub.net/26736162/viewspace-1458654/【推荐】 oracle控制文件在缺失归档日志的情况下的恢复http://blog.itpub.net/26736162/viewspace-1426552/【推荐】 ORACLE 只读数据文件备份与恢复http://blog.itpub.net/26736162/viewspace-1425283/前段时间公司小y给我们培训了下dul恢复truncate的数据,接下来几天我一直在研究truncate的恢复,想总结一下truncate的恢复方法,但是碰到了BBED,可以通过BBED来恢复,可是这个工具不熟悉,之前没用过,其实老早就听说了这个工具,一直想学BBED,但因为一直没碰到实际用途,也一直没有学习,现在碰到了就先研究了BBED了,truncate的恢复过段时间再发blog吧。本文先给大家介绍了下数据库启动过程中的介质恢复的一些知识点,然后介绍了BBED修改数据文件头的办法推进SCN号来实现完全恢复,而不用resetlogs来打开库,利用隐含参数_allow_resetlogs_corruption来打开数据库只是一个插曲。我们做实验的时候分2种情况来实验,一种是linux环境,一种是aix环境,linux下我们采用bbed及隐含参数_allow_resetlogs_corruption来恢复,其中推进scn号的时候直接推进到最新的scn号,和其它的数据文件头的scn号保持一致,aix环境下我们采用删除其中的一个归档文件,修改scn的时候修改到丢失的归档文件的scn号,这样可以模拟尽可能少的数据丢失的情况,加深对redo apply的进一步了解。这个章节相关知识点还是需要了解一下的,小麦苗已经整理好了,和以往blog不太一样,内容有点多。scn号与oracle数据库恢复过程有着密切的关系,只有很好地理解了这层关系,才能深刻地理解恢复的原理,从而才能很好地解决这方面的问题。CKPT进程在checkpoint发生时,将当时的SCN号写入数据文件头和控制文件,同时通知DBWR进程将数据块写到数据文件。CKPT进程也会在控制文件中记录RBA(redo block address),以标志Recovery需要从日志中哪个地方开始。与checkpoint相关的SCN号有四个,其中三个存在控制文件中,一个存放在数据文件头中。这四个分别是:1.System Checkpoint SCN 当checkpoint完成后,ORACLE将System Checkpoint SCN号存放在控制文件中。我们可以通过下面SQL语句查询:select checkpoint_change# from v$database;2.Datafile Checkpoint SCN 当checkpoint完成后,ORACLE将Datafile Checkpoint SCN号存放在控制文件中。我们可以通过下面SQL语句查询所有数据文件的Datafile Checkpoinnt SCN号。select name,checkpoint_change# from v$datafile;3.Start SCN号 ORACLE将Start SCN号存放在数据文件头中。这个SCN用于检查数据库启动过程是否需要做media recovery.我们可以通过以下SQL语句查询:select name,checkpoint_change# from v$datafile_header;4.End SCN号 ORACLE将End SCN号存放在控制文件中。这个SCN号用于检查数据库启动过程是否需要做instance recovery.我们可以通过以下SQL语句查询:select name,last_change# from v$datafile;在数据库正常运行的情况下,对可读写的,online的数据文件,该SCN号为NULL.select checkpoint_change# from v$database; SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; select file#,online_status,change# from v$recover_file; 在数据库启动过程中,当System Checkpoint SCN、Datafile Checkpoint SCN和Start SCN号都相同时,数据库可以正常启动,不需要做media recovery.三者当中有一个不同时,则需要做media recovery.ORACLE在启动过程中首先检查是否需要media recovery,然后再检查是否需要instance recovery.如果数据库的正常关闭的话,将会触发一个checkpoint,同时将数据文件的END SCN号设置为相应数据文件的Start SCN号。当数据库启动时,发现它们是一致的,则不需要做instance recovery。在数据库正常启动后,ORACLE会将END SCN号设置为NULL.如果数据库异常关闭的话,则END SCN号将为NULL.则需要做instance recovery.为什么ORACLE会在控制文件中记录System checkpoint SCN号的同时,还需要为每个数据文件记录Datafile Checkpoint SCN号?原因有二:1.对只读表空间,其数据文件的Datafile Checkpoint SCN、Start SCN和END SCN号均相同。这三个SCN在表空间处于只读期间都将被冻结。2.如果控制文件不是当前的控制文件,则System checkpoint会小于Start SCN或END SCN号。记录这些SCN号,可以区分控制文件是否是当前的控制文件。当有一个Start SCN号超过了System Checkpoint SCN号时,则说明控制文件不是当前的控制文件,因此在做recover时需要采用using backup controlfile。这是为什么需要记录SystemCheckpoint SCN的原因之一。这里需要一提的是,当重建控制文件的时候,System Checkpoint SCN为0,Datafile Checkpoint SCN的数据来自于Start SCN。根据上述的描述,此时需要采用using backup controlfile做recovery.一个表空间的数据文件损坏,使用以前的备份进行恢复,但是需要的归档文件无法提供,而且该表空间存放的是历史的数据,很少改变,但由于其它的原因(定时的往该表空间存储新数据),无法变成只读模式。这种情况下由于缺少归档,数据库无法recovery,但是跟该表空间相关的数据改变很少或者没有,这种情况下我们可以通过改变数据文件头的检查点号,让oracle避开对该文件的检查,实现完全恢复,及时打开数据库。1、数据库异常断电,导致users表空间的数据文件损坏2、从早期的备份中转储数据文件到目标位置3、对数据库进行recovery,假如归档日志损坏,该表空间没有被修改,但是没有变成readonly,数据库无法做完全recovery,所以无法打开:SQL> alter database open;alter database open * ERROR at line 1:ORA-01113: file 4 needs media recoveryORA-01110: data file 4: ‘/u01/app/oracle/oradata/TIANJIN/users01.dbf’SQL> recover database;ORA-00279: change 1951719 generated at 08/25/2012 13:52:08 needed for thread 1 ORA-00289: suggestion :/home/oracle/oracle/product/10.2.0/db_1/dbs/arch2_107_783745676.dbfORA-00280: change 1951719 for thread 1 is in sequence #107Specify log: {=suggested | filename | AUTO | CANCEL}autoORA-00308: cannot open archived log’/home/oracle/oracle/product/10.2.0/db_1/dbs/arch2_107_783745676.dbf’ORA-27037: unable to obtain file statusLinux Error: 2: No such file or directoryAdditional information: 34、由于该表空间没有被修改,归档日志里面应该没有记录有关该表空间被改变的信息,但是oracle不知道,所以它必须要用到归档,才能够进行recovery,此时,我们的解决办法是:把该表空间的数据文件头的检查点号改成跟控制文件记录的一样,那么oracle就不会做介质恢复,只做实例恢复,则就能够recovery成功,可以使用bbed来实现。将数据库文件copy到linux或aix的FS中,BBED修改完成后在copy回数据库的文件位置。RBA就是redo entries在重做日志文件中所对应的地址 A”Redo Block Address” (RBA) describes a physical location within aredo log file.RBA 由以下三部分组成: (1)the log file sequence number (4 bytes) (2)the log file block number (4 bytes) (3)the byte offset into the block at which the redo record starts (2bytes)如:RBA[0x19.2.10] 代表 Log squence25, Block number 2 with byte offset 16.注意这里的格式:都是16进行。Redo 与checkpoint 关系很大,当设置log_checkpoints_to_alert 参数为true后,checkpoint 发生时会写入alert log里。 项目
db
db 类型 单实例 db version 11.2.0.3.0 db 存储 FS 主机IP地址/hosts配置 192.168.59.129 OS版本及kernel版本 Linux rhel5 2.6.18-194.el5 64位 归档模式 Archive Mode ORACLE_SID ora11g 首先我们OS级别删除system文件,删除所有归档文件,然后利用以前的备份来还原system文件,最后利用BBED修改文件头,推进SCN号来打开数据库,另外一个实验是利用隐含参数_allow_resetlogs_corruption来打开数据库,能正常打开数据库就说明实验成功,关于丢不丢失数据这个另当别论,多一种恢复手段总是好事。首先,rman备份1号system数据文件:[oracle@rhel5:/home/oracle]# rman target /Recovery Manager: Release 11.2.0.3.0 – Production on Thu Apr 7 17:00:17 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database: ORA11G (DBID=8302811)RMAN> list backupset;using target database control file instead of recovery catalogspecification does not match any backup in the repositoryRMAN> list copy;specification does not match any datafile copy in the repositoryspecification does not match any control file copy in the repositoryspecification does not match any archived log in the repositoryRMAN> backup datafile 1;Starting backup at 2016-04-07 17:00:35allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=133 device type=DISKchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00001 name=/u01/app/oracle/oradata/ora11g/system01.dbfchannel ORA_DISK_1: starting piece 1 at 2016-04-07 17:00:36channel ORA_DISK_1: finished piece 1 at 2016-04-07 17:03:24piece handle=/u01/app/oracle/fast_recovery_area/ORA11G/backupset/2016_04_07/o1_mf_nnndf_TAG20160407T170035_cjd8fn42_.bkp tag=TAG20160407T170035 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:02:49channel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setincluding current control file in backup setincluding current SPFILE in backup setchannel ORA_DISK_1: starting piece 1 at 2016-04-07 17:03:26channel ORA_DISK_1: finished piece 1 at 2016-04-07 17:03:29piece handle=/u01/app/oracle/fast_recovery_area/ORA11G/backupset/2016_04_07/o1_mf_ncsnf_TAG20160407T170035_cjd8lygf_.bkp tag=TAG20160407T170035 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:03Finished backup at 2016-04-07 17:03:29RMAN>删除1号数据文件且删除归档,重启报错:[oracle@rhel5:/home/oracle]# sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 7 17:05:26 2016Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSYS@ora11g> drop table T_LHR_20160407_02 ;drop table T_LHR_20160407_02 *ERROR at line 1:ORA-00942: table or view does not existSYS@ora11g> create table T_LHR_20160407_02 as select * from all_objects;Table created.SYS@ora11g> update T_LHR_20160407_02 set object_id=100;72458 rows updated.SYS@ora11g> commit;Commit complete.SYS@ora11g> alter database datafile 1 offline;alter database datafile 1 offline*ERROR at line 1:ORA-01541: system tablespace cannot be brought offline; shut down if necessary====》 SYSTEM表空间不能被offline,普通文件可以,我们os级别删除即可SYS@ora11g> select count(1) from T_LHR_20160407_02; COUNT(1)———- 72458SYS@ora11g> col name format a60SYS@ora11g> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#—————— 2217678SYS@ora11g> SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; FILE# NAME CHECKPOINT_CHANGE# LAST_CHANGE# STATUS———- ———————————————————— —————— ———— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2218426 SYSTEM 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2217678 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2217678 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2217678 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2217678 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2217678 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2217678 ONLINE7 rows selected.SYS@ora11g> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME REC CHECKPOINT_CHANGE# STATUS———- ———————————————————— — —————— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf NO 2218426 ONLINE 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf NO 2217678 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf NO 2217678 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf NO 2217678 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf NO 2217678 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf NO 2217678 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf NO 2217678 ONLINE7 rows selected.SYS@ora11g> select file#,online_status,change# from v$recover_file;no rows selectedSYS@ora11g> alter system switch logfile;//System altered.SYS@ora11g>System altered.SYS@ora11g>System altered.SYS@ora11g> col name format a60SYS@ora11g> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#—————— 2220979SYS@ora11g> SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; FILE# NAME CHECKPOINT_CHANGE# LAST_CHANGE# STATUS———- ———————————————————— —————— ———— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2220979 SYSTEM 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2220979 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2220979 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2220979 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2220979 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2220979 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2220979 ONLINE7 rows selected.SYS@ora11g> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME REC CHECKPOINT_CHANGE# STATUS———- ———————————————————— — —————— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf NO 2220979 ONLINE 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf NO 2220979 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf NO 2220979 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf NO 2220979 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf NO 2220979 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf NO 2220979 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf NO 2220979 ONLINE7 rows selected.SYS@ora11g> select file#,online_status,change# from v$recover_file;no rows selected====》切换日志后我们可以看到scn号都保持一致,都是2220979 ,下边我们来删除1号文件SYS@ora11g> ! rm /u01/app/oracle/oradata/ora11g/system01.dbfSYS@ora11g> alter system switch logfile;System altered.SYS@ora11g> /System altered.SYS@ora11g> /====》切换日志过程中有一定几率数据库down掉,若没有就shutdown abort掉,然后重启SYS@ora11g> shutdown abortORACLE instance shut down.SYS@ora11g> startupORACLE instance started.Total System Global Area 513585152 bytesFixed Size 2229864 bytesVariable Size 390072728 bytesDatabase Buffers 113246208 bytesRedo Buffers 8036352 bytesDatabase mounted.ORA-01157: cannot identify/lock data file 1 – see DBWR trace fileORA-01110: data file 1: ‘/u01/app/oracle/oradata/ora11g/system01.dbf’SYS@ora11g> select file#,online_status,change# from v$recover_file; FILE# ONLINE_ CHANGE#———- ——- ———- 1 ONLINE 0SYS@ora11g>SYS@ora11g> archive log list;Database log mode Archive ModeAutomatic archival EnabledArchive destination USE_DB_RECOVERY_FILE_DESTOldest online log sequence 1Next log sequence to archive 2Current log sequence 2SYS@ora11g>SYS@ora11g> show parameter recoveryNAME TYPE VALUE———————————— ———– ——————————db_recovery_file_dest string /u01/app/oracle/fast_recovery_ areadb_recovery_file_dest_size big integer 4122Mrecovery_parallelism integer 0
====》可以看到1号数据文件找不到,然后我们删除归档,确保不能通过recover来恢复[oracle@rhel5:/home/oracle]# cd /u01/app/oracle/fast_recovery_area/ORA11G/archivelog[oracle@rhel5:/u01/app/oracle/fast_recovery_area/ORA11G/archivelog]# lltotal 4drwxr-x— 2 oracle asmadmin 4096 Apr 7 17:09 2016_04_07[oracle@rhel5:/u01/app/oracle/fast_recovery_area/ORA11G/archivelog]# rm -rf *[oracle@rhel5:/u01/app/oracle/fast_recovery_area/ORA11G/archivelog]# cd[oracle@rhel5:/home/oracle]#接下来,我们通过rman来还原1号数据文件,由于归档丢失,不能recover,若非system,undo的数据文件,我们可以offline 掉,然后就可以打开数据库了,但是system必须online才能打开数据库,所以目前数据库不能打开:[oracle@rhel5:/home/oracle]# rman target /Recovery Manager: Release 11.2.0.3.0 – Production on Thu Apr 7 17:10:32 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database: ORA11G (DBID=8302811, not open)RMAN> restore datafile 1;Starting restore at 2016-04-07 17:10:40using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=129 device type=DISKchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ora11g/system01.dbfchannel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORA11G/backupset/2016_04_07/o1_mf_nnndf_TAG20160407T170035_cjd8fn42_.bkpchannel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORA11G/backupset/2016_04_07/o1_mf_nnndf_TAG20160407T170035_cjd8fn42_.bkp tag=TAG20160407T170035channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:01:55Finished restore at 2016-04-07 17:12:36RMAN> recover datafile 1;Starting recover at 2016-04-07 17:14:48using channel ORA_DISK_1starting media recoveryRMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 04/07/2016 17:14:49RMAN-06053: unable to perform media recovery because of missing logRMAN-06025: no backup of archived log for thread 1 with sequence 11 and starting SCN of 2221005 found to restoreRMAN-06025: no backup of archived log for thread 1 with sequence 10 and starting SCN of 2221002 found to restoreRMAN-06025: no backup of archived log for thread 1 with sequence 9 and starting SCN of 2220999 found to restoreRMAN-06025: no backup of archived log for thread 1 with sequence 8 and starting SCN of 2220996 found to restoreRMAN-06025: no backup of archived log for thread 1 with sequence 7 and starting SCN of 2220979 found to restoreRMAN-06025: no backup of archived log for thread 1 with sequence 6 and starting SCN of 2220975 found to restoreRMAN-06025: no backup of archived log for thread 1 with sequence 5 and starting SCN of 2220972 found to restoreRMAN-06025: no backu免费主机域名p of archived log for thread 1 with sequence 4 and starting SCN of 2217677 found to restoreRMAN> recover datafile 1 until sequence 3 thread 1;Starting recover at 2016-04-07 17:20:09using channel ORA_DISK_1RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 04/07/2016 17:20:09RMAN-06556: datafile 1 must be restored from backup older than SCN 2197424====》可以看到由于归档丢失,不能执行recover操作,rman的不完全恢复也不能完成,下边通过SQL的不完全恢复试试[oracle@rhel5:/home/oracle]# sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 7 17:20:49 2016Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSYS@ora11g> archive log listDatabase log mode Archive ModeAutomatic archival EnabledArchive destination USE_DB_RECOVERY_FILE_DESTOldest online log sequence 10Next log sequence to archive 12Current log sequence 12SYS@ora11g> alter database open;alter database open*ERROR at line 1:ORA-01113: file 1 needs media recoveryORA-01110: data file 1: ‘/u01/app/oracle/oradata/ora11g/system01.dbf’SYS@ora11g> recover database using backup controlfile until cancel;ORA-00279: change 2218426 generated at 04/07/2016 17:00:36 needed for thread 1ORA-00289: suggestion : /u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arcORA-00280: change 2218426 for thread 1 is in sequence #4Specify log: {=suggested | filename | AUTO | CANCEL}autoORA-00308: cannot open archived log ‘/u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arc’ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3ORA-00308: cannot open archived log ‘/u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arc’ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error belowORA-01194: file 2 needs more recovery to be consistentORA-01110: data file 2: ‘/u01/app/oracle/oradata/ora11g/sysaux01.dbf’SYS@ora11g> alter database open;alter database open*ERROR at line 1:ORA-01589: must use RESETLOGS or NORESETLOGS option for database openSYS@ora11g> alter database open ressetlogs;alter database open ressetlogs *ERROR at line 1:ORA-02288: invalid OPEN modeSYS@ora11g> alter database open resetlogs;alter database open resetlogs*ERROR at line 1:ORA-01194: file 2 needs more recovery to be consistentORA-01110: data file 2: ‘/u01/app/oracle/oradata/ora11g/sysaux01.dbf’SYS@ora11g> col name format a60SYS@ora11g> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#—————— 2221005SYS@ora11g> SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; FILE# NAME CHECKPOINT_CHANGE# LAST_CHANGE# STATUS———- ———————————————————— —————— ———— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2221005 SYSTEM 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2221005 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2221005 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2221005 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2221005 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2221005 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2221005 ONLINE7 rows selected.SYS@ora11g> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME REC CHECKPOINT_CHANGE# STATUS———- ———————————————————— — —————— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2218426 ONLINE 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2221005 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2221005 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2221005 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2221005 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2221005 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2221005 ONLINE7 rows selected.SYS@ora11g> select file#,online_status,change# from v$recover_file; FILE# ONLINE_ CHANGE#———- ——- ———- 1 ONLINE 2218426SYS@ora11g>可以看到1号文件和其他文件的Ckp SCN 不同,所以数据库不能打开,下边分别介绍基于隐含参数_allow_resetlogs_corruption 和 BBED修改文件头来恢复打开数据库。[oracle@rhel5:/home/oracle]# sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 7 17:20:49 2016Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSYS@ora11g> archive log listDatabase log mode Archive ModeAutomatic archival EnabledArchive destination USE_DB_RECOVERY_FILE_DESTOldest online log sequence 10Next log sequence to archive 12Current log sequence 12SYS@ora11g> alter database open;alter database open*ERROR at line 1:ORA-01113: file 1 needs media recoveryORA-01110: data file 1: ‘/u01/app/oracle/oradata/ora11g/system01.dbf’SYS@ora11g> recover database using backup controlfile until cancel;ORA-00279: change 2218426 generated at 04/07/2016 17:00:36 needed for thread 1ORA-00289: suggestion : /u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arcORA-00280: change 2218426 for thread 1 is in sequence #4Specify log: {=suggested | filename | AUTO | CANCEL}autoORA-00308: cannot open archived log ‘/u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arc’ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3ORA-00308: cannot open archived log ‘/u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arc’ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error belowORA-01194: file 2 needs more recovery to be consistentORA-01110: data file 2: ‘/u01/app/oracle/oradata/ora11g/sysaux01.dbf’SYS@ora11g> alter database open;alter database open*ERROR at line 1:ORA-01589: must use RESETLOGS or NORESETLOGS option for database openSYS@ora11g> alter database open resetlogs;alter database open resetlogs*ERROR at line 1:ORA-01194: file 2 needs more recovery to be consistentORA-01110: data file 2: ‘/u01/app/oracle/oradata/ora11g/sysaux01.dbf’SYS@ora11g> col name format a60SYS@ora11g> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#—————— 2221005SYS@ora11g> SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; FILE# NAME CHECKPOINT_CHANGE# LAST_CHANGE# STATUS———- ———————————————————— —————— ———— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2221005 SYSTEM 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2221005 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2221005 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2221005 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2221005 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2221005 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2221005 ONLINE7 rows selected.SYS@ora11g> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME REC CHECKPOINT_CHANGE# STATUS———- ———————————————————— — —————— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2218426 ONLINE 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2221005 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2221005 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2221005 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2221005 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2221005 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2221005 ONLINE7 rows selected.SYS@ora11g> select file#,online_status,change# from v$recover_file; FILE# ONLINE_ CHANGE#———- ——- ———- 1 ONLINE 2218426SYS@ora11g>SYS@ora11g>SYS@ora11g> alter system set “_allow_resetlogs_corruption”=true scope=spfile;System altered.SYS@ora11g> recover database using backup controlfile until cancel;ORA-00279: change 2218426 generated at 04/07/2016 17:00:36 needed for thread 1ORA-00289: suggestion : /u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arcORA-00280: change 2218426 for thread 1 is in sequence #4Specify log: {=suggested | filename | AUTO | CANCEL}autoORA-00308: cannot open archived log ‘/u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arc’ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3ORA-00308: cannot open archived log ‘/u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arc’ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error belowORA-01194: file 2 needs more recovery to be consistentORA-01110: data file 2: ‘/u01/app/oracle/oradata/ora11g/sysaux01.dbf’SYS@ora11g> alter database open;alter database open*ERROR at line 1:ORA-01589: must use RESETLOGS or NORESETLOGS option for database openSYS@ora11g>SYS@ora11g> alter database open resetlogs;alter database open resetlogs*ERROR at line 1:ORA-01194: file 2 needs more recovery to be consistentORA-01110: data file 2: ‘/u01/app/oracle/oradata/ora11g/sysaux01.dbf’====》 不完全恢复不能打开数据库,只能采用隐含参数了SYS@ora11g>SYS@ora11g> startup forceORACLE instance started.Total System Global Area 513585152 bytesFixed Size 2229864 bytesVariable Size 390072728 bytesDatabase Buffers 113246208 bytesRedo Buffers 8036352 bytesDatabase mounted.ORA-01589: must use RESETLOGS or NORESETLOGS option for database openSYS@ora11g> alter database open resetlogs;alter database open resetlogs*ERROR at line 1:ORA-00603: ORACLE server session terminated by fatal errorORA-00600: internal error code, arguments: [2662], [0], [2218438], [0], [2218967], [12583040], [], [], [], [], [], []ORA-00600: internal error code, arguments: [2662], [0], [2218437], [0], [2218967], [12583040], [], [], [], [], [], []ORA-01092: ORACLE instance terminated. Disconnection forcedORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Process ID: 15341Session ID: 191 Serial number: 3SYS@ora11g> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@rhel5:/home/oracle]# sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 7 17:28:54 2016Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to an idle instance.SYS@ora11g> startup mountORACLE instance started.Total System Global Area 513585152 bytesFixed Size 2229864 bytesVariable Size 390072728 bytesDatabase Buffers 113246208 bytesRedo Buffers 8036352 bytesDatabase mounted.SYS@ora11g> alter database open;Database altered.SYS@ora11g> col name format a60SYS@ora11g> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#—————— 2238438SYS@ora11g> SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; FILE# NAME CHECKPOINT_CHANGE# LAST_CHANGE# STATUS———- ———————————————————— —————— ———— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2238438 SYSTEM 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2238438 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2238438 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2238438 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2238438 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2238438 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2238438 ONLINE7 rows selected.SYS@ora11g> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME REC CHECKPOINT_CHANGE# STATUS———- ———————————————————— — —————— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf NO 2238438 ONLINE 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf NO 2238438 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf NO 2238438 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf NO 2238438 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf NO 2238438 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf NO 2238438 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf NO 2238438 ONLINE7 rows selected.====》ckp scn 一致,数据库打开,下边我们把_allow_resetlogs_corruption这个参数从spfile中删除,然后备份数据库,我们测试就把该参数删除即可SYS@ora11g> alter system set “_allow_resetlogs_corruption”=false scope=spfile;System altered.SYS@ora11g> alter system reset “_allow_resetlogs_corruption” scope=spfile sid=’*’;System altered.SYS@ora11g> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SYS@ora11g> startupORACLE instance started.Total System Global Area 513585152 bytesFixed Size 2229864 bytesVariable Size 390072728 bytesDatabase Buffers 113246208 bytesRedo Buffers 8036352 bytesDatabase mounted.Database opened.SYS@ora11g> show parameter _allow_resetlogs_corruptionSYS@ora11g>====》隐含参数已从spfile中清除掉了,备份数据库即可告警日志:ALTER DATABASE OPENErrors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc:ORA-01589: must use RESETLOGS or NORESETLOGS option for database openORA-1589 signalled during: ALTER DATABASE OPEN…alter database open resetlogsRESETLOGS is being done without consistancy checks. This may resultin a corrupted database. The database should be recreated.RESETLOGS after incomplete recovery UNTIL CHANGE 2218426Archived Log entry 46 added for thread 1 sequence 10 ID 0x94f151 dest 1:Thu Apr 07 17:28:15 2016Archived Log entry 47 added for thread 1 sequence 11 ID 0x94f151 dest 1:Archived Log entry 48 added for thread 1 sequence 12 ID 0x94f151 dest 1:Clearing online redo logfile 1 /u01/app/oracle/oradata/ora11g/redo01.logClearing online log 1 of thread 1 sequence number 10Clearing online redo logfile 1 completeClearing online redo logfile 2 /u01/app/oracle/oradata/ora11g/redo02.logClearing online log 2 of thread 1 sequence number 11Clearing online redo logfile 2 completeClearing online redo logfile 3 /u01/app/oracle/oradata/ora11g/redo03.logClearing online log 3 of thread 1 sequence number 12Clearing online redo logfile 3 completeResetting resetlogs activation ID 9761105 (0x94f151)Online log /u01/app/oracle/oradata/ora11g/redo01.log: Thread 1 Group 1 was previously clearedOnline log /u01/app/oracle/oradata/ora11g/redo02.log: Thread 1 Group 2 was previously clearedOnline log /u01/app/oracle/oradata/ora11g/redo03.log: Thread 1 Group 3 was previously clearedThu Apr 07 17:28:25 2016Setting recovery target incarnation to 4Thu Apr 07 17:28:25 2016Assigning activation ID 9776087 (0x952bd7)LGWR: STARTING ARCH PROCESSESThu Apr 07 17:28:25 2016ARC0 started with pid=21, OS id=15440ARC0: Archival startedLGWR: STARTING ARCH PROCESSES COMPLETEARC0: STARTING ARCH PROCESSESThu Apr 07 17:28:26 2016ARC1 started with pid=22, OS id=15447Thu Apr 07 17:28:26 2016ARC2 started with pid=23, OS id=15450Thread 1 opened at log sequence 1 Current log# 1 seq# 1 mem# 0: /u01/app/oracle/oradata/ora11g/redo01.logSuccessful open of redo thread 1Thu Apr 07 17:28:27 2016MTTR advisory is disabled because FAST_START_MTTR_TARGET is not setThu Apr 07 17:28:27 2016SMON: enabling cache recoveryThu Apr 07 17:28:27 2016ARC3 started with pid=24, OS id=15452ARC1: Archival startedARC2: Archival startedARC1: Becoming the ‘no FAL’ ARCHARC1: Becoming the ‘no SRL’ ARCHARC2: Becoming the heartbeat ARCHARC3: Archival startedARC0: STARTING ARCH PROCESSES COMPLETEErrors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc (incident=39761):ORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Incident details in: /u01/app/oracle/diag/rdbms/ora11g/ora11g/incident/incdir_39761/ora11g_ora_15341_i39761.trcErrors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/incident/incdir_39761/ora11g_ora_15341_i39761.trc:ORA-00308: cannot open archived log ‘/u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_10_cjd8vcy1_.arc’ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3ORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Thu Apr 07 17:28:35 2016Dumping diagnostic data in directory=[cdmp_20160407172835], requested by (instance=1, osid=15341), summary=[incident=39761].Use ADRCI or Support Workbench to package the incident.See Note 411.1 at My Oracle Support for error and packaging details.Errors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc:ORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Errors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc:ORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Error 600 happened during db open, shutting down databaseUSER (ospid: 15341): terminating the instance due to error 600Thu Apr 07 17:28:35 2016ORA-1092 : opitsk aborting processThu Apr 07 17:28:35 2016ORA-1092 : opitsk aborting processInstance terminated by USER, pid = 15341ORA-1092 signalled during: alter database open resetlogs…Errors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc (incident=39762):ORA-00600: internal error code, arguments: [2662], [0], [2218437], [0], [2218967], [12583040], [], [], [], [], [], []ORA-01092: ORACLE instance terminated. Disconnection forcedORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Incident details in: /u01/app/oracle/diag/rdbms/ora11g/ora11g/incident/incdir_39762/ora11g_ora_15341_i39762.trcUse ADRCI or Support Workbench to package the incident.See Note 411.1 at My Oracle Support for error and packaging details.Errors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc (incident=39763):ORA-00600: internal error code, arguments: [2662], [0], [2218438], [0], [2218967], [12583040], [], [], [], [], [], []ORA-00600: internal error code, arguments: [2662], [0], [2218437], [0], [2218967], [12583040], [], [], [], [], [], []ORA-01092: ORACLE instance terminated. Disconnection forcedORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Incident details in: /u01/app/oracle/diag/rdbms/ora11g/ora11g/incident/incdir_39763/ora11g_ora_15341_i39763.trcThu Apr 07 17:28:37 2016Use ADRCI or Support Workbench to package the incident.See Note 411.1 at My Oracle Support for error and packaging details.Errors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc:ORA-00600: internal error code, arguments: [2662], [0], [2218438], [0], [2218967], [12583040], [], [], [], [], [], []ORA-00600: internal error code, arguments: [2662], [0], [2218437], [0], [2218967], [12583040], [], [], [], [], [], []ORA-01092: ORACLE instance terminated. Disconnection forcedORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Errors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc:ORA-27300: OS system dependent operation:semctl failed with status: 22ORA-27301: OS failure message: Invalid argumentORA-27302: failure occurred at: sskgpwpost1ORA-27303: additional information: semid = 4292611ORA-00600: internal error code, arguments: [2662], [0], [2218438], [0], [2218967], [12583040], [], [], [], [], [], []ORA-00600: internal error code, arguments: [2662], [0], [2218437], [0], [2218967], [12583040], [], [], [], [], [], []ORA-01092: ORACLE instance terminated. Disconnection forcedORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Errors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc (incident=39764):ORA-00600: internal error code, arguments: [], [], [], [], [], [], [], [], [], [], [], []ORA-00600: internal error code, arguments: [2662], [0], [2218438], [0], [2218967], [12583040], [], [], [], [], [], []ORA-00600: internal error code, arguments: [2662], [0], [2218437], [0], [2218967], [12583040], [], [], [], [], [], []ORA-01092: ORACLE instance terminated. Disconnection forcedORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Incident details in: /u01/app/oracle/diag/rdbms/ora11g/ora11g/incident/incdir_39764/ora11g_ora_15341_i39764.trcUse ADRCI or Support Workbench to package the incident.See Note 411.1 at My Oracle Support for error and packaging details.Errors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc:ORA-00600: internal error code, arguments: [], [], [], [], [], [], [], [], [], [], [], []ORA-00600: internal error code, arguments: [2662], [0], [2218438], [0], [2218967], [12583040], [], [], [], [], [], []ORA-00600: internal error code, arguments: [2662], [0], [2218437], [0], [2218967], [12583040], [], [], [], [], [], []ORA-01092: ORACLE instance terminated. Disconnection forcedORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Errors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc:ORA-00600: internal error code, arguments: [2662], [0], [2218438], [0], [2218967], [12583040], [], [], [], [], [], []ORA-00600: internal error code, arguments: [2662], [0], [2218437], [0], [2218967], [12583040], [], [], [], [], [], []ORA-01092: ORACLE instance terminated. Disconnection forcedORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Thu Apr 07 17:28:39 2016Errors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_15341.trc (incident=40809):ORA-00603: ORACLE server session terminated by fatal errorORA-00600: internal error code, arguments: [2662], [0], [2218438], [0], [2218967], [12583040], [], [], [], [], [], []ORA-00600: internal error code, arguments: [2662], [0], [2218437], [0], [2218967], [12583040], [], [], [], [], [], []ORA-01092: ORACLE instance terminated. Disconnection forcedORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Incident details in: /u01/app/oracle/diag/rdbms/ora11g/ora11g/incident/incdir_40809/ora11g_ora_15341_i40809.trcErrors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/incident/incdir_40809/ora11g_ora_15341_i40809.trc:ORA-00603: ORACLE server session terminated by fatal errorORA-00600: internal error code, arguments: [2662], [0], [2218438], [0], [2218967], [12583040], [], [], [], [], [], []ORA-00600: internal error code, arguments: [2662], [0], [2218437], [0], [2218967], [12583040], [], [], [], [], [], []ORA-01092: ORACLE instance terminated. Disconnection forcedORA-00600: internal error code, arguments: [2662], [0], [2218434], [0], [2218967], [12583040], [], [], [], [], [], []Thu Apr 07 17:29:01 2016Adjusting the default value of parameter parallel_max_serversfrom 160 to 135 due to the value of parameter processes (150)Starting ORACLE instance (normal)LICENSE_MAX_SESSION = 0LICENSE_SESSIONS_WARNING = 0Picked latch-free SCN scheme 3Using LOG_ARCHIVE_DEST_1 parameter default value as USE_DB_RECOVERY_FILE_DESTAutotune of undo retention is turned on.IMODE=BRILAT =27LICENSE_MAX_USERS = 0SYS auditing is disabledStarting up:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options.ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1System name: LinuxNode name: rhel5Release: 2.6.18-194.el5Version: #1 SMP Tue Mar 16 21:52:39 EDT 2010Machine: x86_64VM name: VMWare Version: 6Using parameter settings in server-side spfile /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileora11g.oraSystem parameters with non-default values: processes = 150 memory_target = 492M control_files = “/u01/app/oracle/oradata/ora11g/control01.ctl” control_files = “/u01/app/oracle/fast_recovery_area/ora11g/control02.ctl” db_block_size = 8192 compatible = “11.2.0.0.0” db_recovery_file_dest = “/u01/app/oracle/fast_recovery_area” db_recovery_file_dest_size= 4122M _allow_resetlogs_corruption= TRUE undo_tablespace = “UNDOTBS1” remote_login_passwordfile= “EXCLUSIVE” db_domain = “” dispatchers = “(PROTOCOL=TCP) (SERVICE=ora11gXDB)” audit_file_dest = “/u01/app/oracle/admin/ora11g/adump” audit_trail = “DB” db_name = “ora11g” open_cursors = 300 diagnostic_dest = “/u01/app/oracle”Thu Apr 07 17:29:01 2016PMON started with pid=2, OS id=15634Thu Apr 07 17:29:01 2016PSP0 started with pid=3, OS id=15636Thu Apr 07 17:29:02 2016VKTM started with pid=4, OS id=15641 at elevated priorityVKTM running at (1)millisec precision with DBRM quantum (100)msThu Apr 07 17:29:02 2016GEN0 started with pid=5, OS id=15645Thu Apr 07 17:29:02 2016DIAG started with pid=6, OS id=15647Thu Apr 07 17:29:02 2016DBRM started with pid=7, OS id=15649Thu Apr 07 17:29:02 2016DIA0 started with pid=8, OS id=15651Thu Apr 07 17:29:02 2016MMAN started with pid=9, OS id=15655Thu Apr 07 17:29:02 2016DBW0 started with pid=10, OS id=15657Thu Apr 07 17:29:02 2016LGWR started with pid=11, OS id=15660Thu Apr 07 17:29:02 2016CKPT started with pid=12, OS id=15662Thu Apr 07 17:29:02 2016SMON started with pid=13, OS id=15664Thu Apr 07 17:29:02 2016RECO started with pid=14, OS id=15666Thu Apr 07 17:29:02 2016MMON started with pid=15, OS id=15668Thu Apr 07 17:29:02 2016MMNL started with pid=16, OS id=15670starting up 1 dispatcher(s) for network address ‘(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))’…starting up 1 shared server(s) …ORACLE_BASE from environment = /u01/app/oracleThu Apr 07 17:29:03 2016ALTER DATABASE MOUNTThu Apr 07 17:29:06 2016Sweep [inc][40809]: completedSweep [inc][39764]: completedSweep [inc][39763]: completedSweep [inc][39762]: completedSweep [inc][39761]: completedSweep [inc2][40809]: completedSweep [inc2][39764]: completedSweep [inc2][39763]: completedSweep [inc2][39762]: completedSweep [inc2][39761]: completedSuccessful mount of redo thread 1, with mount id 9775647Database mounted in Exclusive ModeLost write protection disabledCompleted: ALTER DATABASE MOUNTThu Apr 07 17:29:11 2016alter database openBeginning crash recovery of 1 threadsparallel recovery started with 3 processesStarted redo scanCompleted redo scanread 1 KB redo, 3 data blocks need recoveryStarted redo application atThread 1: logseq 1, block 3, scn 2218432Recovery of Online Redo Log: Thread 1 Group 1 Seq 1 Reading mem 0 Mem# 0: /u01/app/oracle/oradata/ora11g/redo01.logCompleted redo application of 0.00MBCompleted crash recovery atThread 1: logseq 1, block 5, scn 22384353 data blocks read, 3 data blocks written, 1 redo k-bytes readLGWR: STARTING ARCH PROCESSESThu Apr 07 17:29:11 2016ARC0 started with pid=24, OS id=15751ARC0: Archival startedLGWR: STARTING ARCH PROCESSES COMPLETEARC0: STARTING ARCH PROCESSESThu Apr 07 17:29:12 2016ARC1 started with pid=25, OS id=15756Thread 1 advanced to log sequence 2 (thread open)Thu Apr 07 17:29:12 2016ARC2 started with pid=26, OS id=15758Thread 1 opened at log sequence 2 Current log# 2 seq# 2 mem# 0: /u01/app/oracle/oradata/ora11g/redo02.logSuccessful open of redo thread 1MTTR advisory is disabled because FAST_START_MTTR_TARGET is not setSMON: enabling cache recoveryThu Apr 07 17:29:12 2016ARC3 started with pid=27, OS id=15760ARC1: Archival startedARC2: Archival startedARC1: Becoming the ‘no FAL’ ARCHARC1: Becoming the ‘no SRL’ ARCHARC2: Becoming the heartbeat ARCHArchived Log entry 49 added for thread 1 sequence 1 ID 0x952bd7 dest 1:ARC3: Archival startedARC0: STARTING ARCH PROCESSES COMPLETE[15725] Successfully onlined Undo Tablespace 2.Undo initialization finished serial:0 start:85654704 end:85655584 diff:880 (8 seconds)Dictionary check beginningDictionary check completeVerifying file header compatibility for 11g tablespace encryption..Verifying 11g file header compatibility for tablespace encryption completedThu Apr 07 17:29:13 2016SMON: enabling tx recoveryDatabase Characterset is AL32UTF8No Resource Manager plan activereplication_dependency_tracking turned off (no async multimaster replication found)Starting background process QMNCThu Apr 07 17:29:16 2016QMNC started with pid=28, OS id=15774LOGSTDBY: Validating controlfile with logical metadataLOGSTDBY: Validation completeCompleted: alter database openThu Apr 07 17:29:24 2016db_recovery_file_dest_size of 4122 MB is 18.36% used. This is auser-specified limit on the amount of space that will be used by thisdatabase for recovery-related files, and does not reflect the amount ofspace available in the underlying filesystem or ASM diskgroup.Thu Apr 07 17:29:24 2016Starting background process CJQ0Thu Apr 07 17:29:24 2016CJQ0 started with pid=31, OS id=15820通过_allow_resetlogs_corruption跳过数据库的一致性检查,成功打开数据库,但也有些案例由于各种原因即使加上该参数也不能打开库,这个时候就得靠我们的BBED了,切记resetlogs后立即备份数据库。首先查看system文件头的scn号:[oracle@rhel5:/home/oracle]# sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 7 17:41:50 2016Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSYS@ora11g> col name format a60SYS@ora11g> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#—————— 2239089SYS@ora11g> SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; FILE# NAME CHECKPOINT_CHANGE# LAST_CHANGE# STATUS———- ———————————————————— —————— ———— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2239089 SYSTEM 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2239089 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2239089 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2239089 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2239089 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2239089 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2239089 ONLINE7 rows selected.SYS@ora11g> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME REC CHECKPOINT_CHANGE# STATUS———- ———————————————————— — —————— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2218426 ONLINE 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf NO 2239089 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf NO 2239089 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf NO 2239089 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf NO 2239089 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf NO 2239089 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf NO 2239089 ONLINE7 rows selected.SYS@ora11g> select file#,online_status,change# from v$recover_file; FILE# ONLINE_ CHANGE#———- ——- ———- 1 ONLINE 2218426SYS@ora11g>SYS@ora11g> select to_char(2239089,’xxxxxxxxxxx’),to_char(2218426,’xxxxxxxxxxx’) FROM DUAL;TO_CHAR(2239 TO_CHAR(2218———— ———— 222a71 21d9ba ====》将十进制转换为十六进制SYS@ora11g>当前ckp scn是2218426(十六进制:21d9ba),需要修改ckp scn到2239089(十六进制:222a71)才可以启动数据库,下边我们通过bbed来修改: BBED编译准备代码,编译过程参考:make -f $ORACLE_HOME/rdbms/lib/ins_rdbms.mk BBED=$ORACLE_HOME/bin/bbed $ORACLE_HOME/bin/bbedvi /home/oracle/file.txtset line 9999 pagesize 9999select file#||’ ‘||name||’ ‘||bytes from v$datafile;vi /home/oracle/bbed.parblocksize=8192listfile=/home/oracle/file.txtmode=editbbed parfile=/home/oracle/bbed.par [oracle@rhel5:/home/oracle]# lltotal 51328-rwxr-xr-x 1 oracle dba 56 Apr 7 09:38 bbed.par-rwxr-xr-x 1 oracle dba 27648 Apr 7 16:13 bifile.bbddrwxr-xr-x 2 oracle dba 4096 Apr 7 09:38 Desktopdrwxr-xr-x 2 oracle dba 4096 Apr 7 09:38 dul-rwxr-xr-x 1 oracle dba 393 Apr 7 17:46 file.txtdrwxr-xr-x 8 oracle dba 4096 Apr 7 09:38 gdul-rwxr-xr-x 1 oracle dba 7354 Apr 7 16:31 log.bbd-rwxr-xr-x 1 oracle dba 52436992 Apr 7 09:38 lxtbs01.dbfdrwxr-xr-x 3 oracle oinstall 4096 Apr 7 10:41 oradiag_oracledrwxr-xr-x 2 oracle dba 4096 Apr 7 09:38 rman_bak[oracle@rhel5:/home/oracle]# cat bbed.parblocksize=8192listfile=/home/oracle/file.txtmode=edit[oracle@rhel5:/home/oracle]# cat file.txt1 /u01/app/oracle/oradata/ora11g/system01.dbf 7549747202 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 7654604803 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 734003204 /u01/app/oracle/oradata/ora11g/users01.dbf 117964805 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 104857606 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 209715207 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 52428800[oracle@rhel5:/home/oracle]# bbed parfile=bbed.parPassword:BBED: Release 2.0.0.0.0 – Limited Production on Thu Apr 7 17:46:53 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.************* !!! For Oracle Internal Use only !!! ***************BBED> infoFile# Name Size(blks)—– —- ———- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 92160 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 93440 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 8960 4 /u01/app/oracle/oradata/ora11g/users01.dbf 1440 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 1280 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2560 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 6400BBED> set dba 1,1 DBA 0x00400001 (4194305 1,1)BBED> show FILE# 1 BLOCK# 1 OFFSET 0 DBA 0x00400001 (4194305 1,1) FILENAME /u01/app/oracle/oradata/ora11g/system01.dbf BIFILE bifile.bbd LISTFILE /home/oracle/file.txt BLOCKSIZE 8192 MODE Edit EDIT Unrecoverable IBASE Dec OBASE Dec WIDTH 80 COUNT 512 LOGFILE log.bbd SPOOL NoBBED>BBED> p kcvfhckpstruct kcvfhckp, 36 bytes @484 struct kcvcpscn, 8 bytes @484 ub4 kscnbas @484 0x0021d9ba ub2 kscnwrp @488 0x0000 ub4 kcvcptim @492 0x36277bb4 ub2 kcvcpthr @496 0x0001 union u, 12 bytes @500 struct kcvcprba, 12 bytes @500 ub4 kcrbaseq @500 0x00000004 ub4 kcrbabno @504 0x0000099d ub2 kcrbabof @508 0x0010 ub1 kcvcpetb[0] @512 0x02 ub1 kcvcpetb[1] @513 0x00 ub1 kcvcpetb[2] @514 0x00 ub1 kcvcpetb[3] @515 0x00 ub1 kcvcpetb[4] @516 0x00 ub1 kcvcpetb[5] @517 0x00 ub1 kcvcpetb[6] @518 0x00 ub1 kcvcpetb[7] @519 0x00====》这里我们看到0x0021d9ba 这个值就是我们刚刚查到的1号数据文件的文件头的ckp scn号,我们dump一下文件头块,看看是如何存储的:BBED> d /v dba 1,1 offset 484 count 64File: /u01/app/oracle/oradata/ora11g/system01.dbf (1)Block: 1 Offsets: 484 to 547 Dba:0x00400001——————————————————-bad92100 00000000 b47b2736 01000000 l ……..04000000 9d090000 1000e080 02000000 l …………00000000 00000000 00000000 00000000 l …………….00000000 00000000 00000000 00000000 l …………….====》很奇怪,我们看到的是bad92100,而不是我们期望的0021d9ba,2个存储正好相反,我们的实验环境是linux的,属于little字节序,在aix下这2个值的顺序是一致的,这一点尤其得注意,下边我们通过modify修改的时候也必须倒置,也就是原本的2239089(十六进制:222a71) ,修改的时候为:712a71,还有2个0必须省略,如下BBED> modify /x 712a22 dba 1,1 offset 484Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) yFile: 免费主机域名/u01/app/oracle/oradata/ora11g/system01.dbf (1)Block: 1 Offsets: 484 to 547 Dba:0x00400001————————————————————————712a2200 00000000 b47b2736 01000000 04000000 9d090000 1000e080 0200000000000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000BBED> d /v dba 1,1 offset 484 count 64File: /u01/app/oracle/oradata/ora11g/system01.dbf (1)Block: 1 Offsets: 484 to 547 Dba:0x00400001——————————————————-712a2200 00000000 b47b2736 01000000 l q*”………04000000 9d090000 1000e080 02000000 l …………00000000 00000000 00000000 00000000 l …………….00000000 00000000 00000000 00000000 l …………….====》可以看到已经修改了BBED> p kcvfhckpstruct kcvfhckp, 36 bytes @484 struct kcvcpscn, 8 bytes @484 ub4 kscnbas @484 0x00222a71 ub2 kscnwrp @488 0x0000 ub4 kcvcptim @492 0x36277bb4 ub2 kcvcpthr @496 0x0001 union u, 12 bytes @500 struct kcvcprba, 12 bytes @500 ub4 kcrbaseq @500 0x00000004 ub4 kcrbabno @504 0x0000099d ub2 kcrbabof @508 0x0010 ub1 kcvcpetb[0] @512 0x02 ub1 kcvcpetb[1] @513 0x00 ub1 kcvcpetb[2] @514 0x00 ub1 kcvcpetb[3] @515 0x00 ub1 kcvcpetb[4] @516 0x00 ub1 kcvcpetb[5] @517 0x00 ub1 kcvcpetb[6] @518 0x00 ub1 kcvcpetb[7] @519 0x00BBED> sum apply====》应用bbed的修改Check value for File 1, Block 1:current = 0x2a6c, required = 0x2a6cBBED>查看数据文件的ckp scn号,已经保持一致了:SYS@ora11g> col name format a50SYS@ora11g> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#—————— 2239089SYS@ora11g> SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; FILE# NAME CHECKPOINT_CHANGE# LAST_CHANGE# STATUS———- ————————————————– —————— ———— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2239089 SYSTEM 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2239089 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2239089 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2239089 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2239089 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2239089 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2239089 ONLINE7 rows selected.SYS@ora11g> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME REC CHECKPOINT_CHANGE# STATUS———- ————————————————– — —————— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2239089 ONLINE 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf NO 2239089 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf NO 2239089 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf NO 2239089 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf NO 2239089 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf NO 2239089 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf NO 2239089 ONLINE7 rows selected.SYS@ora11g> select file#,online_status,change# from v$recover_file; FILE# ONLINE_ CHANGE#———- ——- ———- 1 ONLINE 2239089SYS@ora11g> recover datafile 1;Media recovery complete.SYS@ora11g> select file#,online_status,change# from v$recover_file;no rows selectedSYS@ora11g> alter database open;Database altered.====》 数据库正常打开,没有使用resetlogs方式,o(∩_∩)o 哈哈一般情况下数据库可以正常打开,下边要做的就是备份数据库,或者expdp重新组织库,值得说明的是,我做实验是先利用隐含参数去恢复的,做了resetlogs操作,然后采用bbed来恢复,结果recover数据文件的时候说备份属于一个orphan incarnation,这个其实rman里边reset一下就好了,下边的内容也属于插曲,简单记录一下:SYS@ora11g> recover datafile 1;ORA-00283: recovery session canceled due to errorsORA-19909: datafile 1 belongs to an orphan incarnationORA-01110: data file 1: ‘/u01/app/oracle/oradata/ora11g/system01.dbf’SYS@ora11g> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsThu Apr 07 17:51:50 2016告警日志看到属于incarnation#=3:ALTER DATABASE RECOVER datafile 1Media Recovery StartSerial Media Recovery startedDatafile 1 (ckpscn 2239089) is orphaned on incarnation#=3Media Recovery failed with error 19909ORA-283 signalled during: ALTER DATABASE RECOVER datafile 1 …下边通过rman来reset database:[oracle@rhel5:/home/oracle]# rman target /Recovery Manager: Release 11.2.0.3.0 – Production on Thu Apr 7 17:52:47 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database: ORA11G (DBID=8302811, not open)RMAN> list incarnation of database;using target database control file instead of recovery catalogList of Database IncarnationsDB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time——- ——- ——– —————- — ———- ———-1 1 ORA11G 8302811 PARENT 1 2011-09-17 09:46:042 2 ORA11G 8302811 PARENT 995548 2016-03-21 11:53:043 3 ORA11G 8302811 PARENT 2157406 2016-04-07 16:44:294 4 ORA11G 8302811 CURRENT 2218427 2016-04-07 17:28:05RMAN> list backupset;List of Backup Sets===================BS Key Type LV Size Device Type Elapsed Time Completion Time——- —- — ———- ———– ———— ——————-8 Full 628.38M DISK 00:02:46 2016-04-07 17:03:22 BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20160407T170035 Piece Name: /u01/app/oracle/fast_recovery_area/ORA11G/backupset/2016_04_07/o1_mf_nnndf_TAG20160407T170035_cjd8fn42_.bkp List of Datafiles in backup set 8 File LV Type Ckp SCN Ckp Time Name —- — —- ———- ——————- —- 1 Full 2218426 2016-04-07 17:00:36 /u01/app/oracle/oradata/ora11g/system01.dbfBS Key Type LV Size Device Type Elapsed Time Completion Time——- —- — ———- ———– ———— ——————-9 Full 9.64M DISK 00:00:02 2016-04-07 17:03:27 BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20160407T170035 Piece Name: /u01/app/oracle/fast_recovery_area/ORA11G/backupset/2016_04_07/o1_mf_ncsnf_TAG20160407T170035_cjd8lygf_.bkp SPFILE Included: Modification time: 2016-04-07 16:49:24 SPFILE db_unique_name: ORA11G Control File Included: Ckp SCN: 2218482 Ckp time: 2016-04-07 17:03:24RMAN> reset database to incarnation 3;database reset to incarnation 3RMAN> list incarnation of database;List of Database IncarnationsDB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time——- ——- ——– —————- — ———- ———-1 1 ORA11G 8302811 PARENT 1 2011-09-17 09:46:042 2 ORA11G 8302811 PARENT 995548 2016-03-21 11:53:043 3 ORA11G 8302811 CURRENT 2157406 2016-04-07 16:44:294 4 ORA11G 8302811 ORPHAN 2218427 2016-04-07 17:28:05RMAN> exitRecovery Manager complete.[oracle@rhel5:/home/oracle]# sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 7 17:54:33 2016Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSYS@ora11g> col name format a50SYS@ora11g> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#—————— 2239089SYS@ora11g> SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; FILE# NAME CHECKPOINT_CHANGE# LAST_CHANGE# STATUS———- ————————————————– —————— ———— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2239089 SYSTEM 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2239089 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2239089 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2239089 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2239089 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2239089 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2239089 ONLINE7 rows selected.SYS@ora11g> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME REC CHECKPOINT_CHANGE# STATUS———- ————————————————– — —————— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2239089 ONLINE 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf NO 2239089 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf NO 2239089 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf NO 2239089 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf NO 2239089 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf NO 2239089 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf NO 2239089 ONLINE7 rows selected.SYS@ora11g> select file#,online_status,change# from v$recover_file; FILE# ONLINE_ CHANGE#———- ——- ———- 1 ONLINE 2239089SYS@ora11g>SYS@ora11g> recover datafile 1;ORA-00279: change 2239089 generated at 04/07/2016 17:00:36 needed for thread 1ORA-00289: suggestion : /u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arcORA-00280: change 2239089 for thread 1 is in sequence #4Specify log: {=suggested | filename | AUTO | CANCEL}autoORA-00308: cannot open archived log ‘/u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arc’ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3ORA-00308: cannot open archived log ‘/u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arc’ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3SYS@ora11g> select file#,online_status,change# from v$recover_file; FILE# ONLINE_ CHANGE#———- ——- ———- 1 ONLINE 2239089 2 ONLINE 2239089 3 ONLINE 2239089 4 ONLINE 2239089 5 ONLINE 2239089 6 ONLINE 2239089 7 ONLINE 22390897 rows selected.SYS@ora11g> col name format a50SYS@ora11g> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#—————— 2239089SYS@ora11g> SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; FILE# NAME CHECKPOINT_CHANGE# LAST_CHANGE# STATUS———- ————————————————– —————— ———— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2239089 SYSTEM 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2239089 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2239089 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2239089 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2239089 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2239089 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2239089 ONLINE7 rows selected.SYS@ora11g> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME REC CHECKPOINT_CHANGE# STATUS———- ————————————————– — —————— ——- 1 /u01/app/oracle/oradata/ora11g/system01.dbf 2239089 ONLINE 2 /u01/app/oracle/oradata/ora11g/sysaux01.dbf 2239089 ONLINE 3 /u01/app/oracle/oradata/ora11g/undotbs01.dbf 2239089 ONLINE 4 /u01/app/oracle/oradata/ora11g/users01.dbf 2239089 ONLINE 5 /u01/app/oracle/oradata/ora11g/test_dul01.dbf 2239089 ONLINE 6 /u01/app/oracle/oradata/ora11g/TS_TRUNCATE01.dbf 2239089 ONLINE 7 /u01/app/oracle/oradata/ora11g/lxtbs01.dbf 2239089 ONLINE7 rows selected.SYS@ora11g> select file#,online_status,change# from v$recover_file;recover datafile 1; FILE# ONLINE_ CHANGE#———- ——- ———- 1 ONLINE 2239089 2 ONLINE 2239089 3 ONLINE 2239089 4 ONLINE 2239089 5 ONLINE 2239089 6 ONLINE 2239089 7 ONLINE 22390897 rows selected.SYS@ora11g> alter database open;alter database open*ERROR at line 1:ORA-01589: must use RESETLOGS or NORESETLOGS option for database open====》 看来reset 数据库后只能resetlogs方式打开数据库了SYS@ora11g> alter database open resetlogs;Database altered.SYS@ora11g>告警日志:Thu Apr 07 17:52:29 2016db_recovery_file_dest_size of 4122 MB is 18.36% used. This is auser-specified limit on the amount of space that will be used by thisdatabase for recovery-related files, and does not reflect the amount ofspace available in the underlying filesystem or ASM diskgroup.Thu Apr 07 17:54:07 2016Setting recovery target incarnation to 3Thu Apr 07 17:54:58 2016ALTER DATABASE RECOVER datafile 1Media Recovery StartSerial Media Recovery startedARCH: STARTING ARCH PROCESSESThu Apr 07 17:54:59 2016ARC0 started with pid=21, OS id=20808ARC0: Archival startedARCH: STARTING ARCH PROCESSES COMPLETEARC0: STARTING ARCH PROCESSESWarning: Recovery target destination is in a sibling branchof the controlfile checkpoint. Recovery will only recoverchanges to datafiles.Thu Apr 07 17:55:00 2016ARC1 started with pid=22, OS id=20813Thu Apr 07 17:55:00 2016ARC2 started with pid=23, OS id=20815Thu Apr 07 17:55:00 2016ARC3 started with pid=24, OS id=20817ARC1: Archival startedARC2: Archival startedARC2: Becoming the ‘no FAL’ ARCHARC2: Becoming the ‘no SRL’ ARCHARC1: Becoming the heartbeat ARCHORA-279 signalled during: ALTER DATABASE RECOVER datafile 1 …ARC3: Archival startedARC0: STARTING ARCH PROCESSES COMPLETEThu Apr 07 17:55:22 2016ALTER DATABASE RECOVER CONTINUE DEFAULTMedia Recovery Log /u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arcErrors with log /u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arcORA-308 signalled during: ALTER DATABASE RECOVER CONTINUE DEFAULT …ALTER DATABASE RECOVER CONTINUE DEFAULTMedia Recovery Log /u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arcErrors with log /u01/app/oracle/fast_recovery_area/ORA11G/archivelog/2016_04_07/o1_mf_1_4_cjd8sssx_.arcORA-308 signalled during: ALTER DATABASE RECOVER CONTINUE DEFAULT …ALTER DATABASE RECOVER CANCELMedia Recovery CanceledCompleted: ALTER DATABASE RECOVER CANCELThu Apr 07 17:55:46 2016ALTER DATABASE RECOVER datafile 1Media Recovery StartSerial Media Recovery startedMedia Recovery failed with error 1610ORA-283 signalled during: ALTER DATABASE RECOVER datafile 1 …Thu Apr 07 17:56:04 2016alter database openErrors in file /u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_20712.trc:ORA-01589: must use RESETLOGS or NORESETLOGS option for database openORA-1589 signalled during: alter database open…alter database open resetlogsRESETLOGS is being done without consistancy checks. This may resultin a corrupted database. The database should be recreated.RESETLOGS after incomplete recovery UNTIL CHANGE 2239089Archived Log entry 77 added for thread 1 sequence 28 ID 0x952bd7 dest 1:Archived Log entry 78 added for thread 1 sequence 29 ID 0x952bd7 dest 1:Archived Log entry 79 added for thread 1 sequence 27 ID 0x952bd7 dest 1:Clearing online redo logfile 1 /u01/app/oracle/oradata/ora11g/redo01.logClearing online log 1 of thread 1 sequence number 28Clearing online redo logfile 1 completeClearing online redo logfile 2 /u01/app/oracle/oradata/ora11g/redo02.logClearing online log 2 of thread 1 sequence number 29Clearing online redo logfile 2 completeClearing online redo logfile 3 /u01/app/oracle/oradata/ora11g/redo03.logClearing online log 3 of thread 1 sequence number 27Thu Apr 07 17:56:16 2016Clearing online redo logfile 3 completeResetting resetlogs activation ID 9776087 (0x952bd7)Online log /u01/app/oracle/oradata/ora11g/redo01.log: Thread 1 Group 1 was previously clearedOnline log /u01/app/oracle/oradata/ora11g/redo02.log: Thread 1 Group 2 was previously clearedOnline log /u01/app/oracle/oradata/ora11g/redo03.log: Thread 1 Group 3 was previously clearedThu Apr 07 17:56:16 2016Setting recovery target incarnation to 5Thu Apr 07 17:56:16 2016Assigning activation ID 9778453 (0x953515)Thread 1 opened at log sequence 1 Current log# 1 seq# 1 mem# 0: /u01/app/oracle/oradata/ora11g/redo01.logSuccessful open of redo thread 1MTTR advisory is disabled because FAST_START_MTTR_TARGET is not setThu Apr 07 17:56:16 2016SMON: enabling cache recovery[20712] Successfully onlined Undo Tablespace 2.Undo initialization finished serial:0 start:87282814 end:87284294 diff:1480 (14 seconds)Dictionary check beginningDictionary check completeVerifying file header compatibility for 11g tablespace encryption..Verifying 11g file header compatibility for tablespace encryption completedSMON: enabling tx recoveryDatabase Characterset is AL32UTF8Thu Apr 07 17:56:27 2016No Resource Manager plan activereplication_dependency_tracking turned off (no async multimaster replication found)Starting background process QMNCThu Apr 07 17:56:29 2016QMNC started with pid=25, OS id=21121LOGSTDBY: Validating controlfile with logical metadataLOGSTDBY: Validation completeThu Apr 07 17:56:36 2016ORA-1 encountered when generating server alert SMG-4120Thu Apr 07 17:56:40 2016Completed: alter database open resetlogsORA-1 encountered when generating server alert SMG-4121Thu Apr 07 17:56:47 2016Starting background process CJQ0Thu Apr 07 17:56:47 2016CJQ0 started with pid=29, OS id=21198Thu Apr 07 17:56:51 2016Time drift detected. Please check VKTM trace file for more details.通过隐含参数或BBED修改文件头都可以恢复这种丢失归档文件情况下的数据文件的恢复,至于丢不丢失数据就看情况了,比如普通文件,被offline 掉了,也没有任何数据更新,那么我们恢复该数据文件后就不会丢失数据。至于哪种方式更好一点,不能一概而论,我测试的时候可能由于多次修改多次resetlogs的缘故,单独的隐含参数或bbed都不能成功打开库,而是两者结合最后修复了,所以还是得灵活运用。小麦苗的箴言:多做实验多思考! 项目
db
db 类型 单实例 db version 11.2.0.4.0 db 存储 FS 主机IP地址/hosts配置 192.168.59.129 OS版本及kernel版本 AIX 7.1 64位 归档模式 Archive Mode ORACLE_SID oralhr 首先我们OS级别删除system文件,删除其中的一个归档文件,利用以前的备份来还原system文件,最后利用BBED修改文件头到丢失日志的下一个日志号来模拟尽可能少的丢失数据的情况。首先,rman备份1号system数据文件:[ZHLHRDB2:oracle]:/home/oracle>rman target /Recovery Manager: Release 11.2.0.4.0 – Production on Mon Apr 11 14:30:41 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database: ORALHR (DBID=394957205)RMAN> list backupset;specification does not match any backup in the repositoryRMAN> list copy;specification does not match any datafile copy in the repositoryspecification does not match any control file copy in the repositoryspecification does not match any archived log in the repositoryRMAN> list archivelog all;specification does not match any archived log in the repositoryRMAN> backup datafile 1;Starting backup at 2016-04-11 14:31:42using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00001 name=/oracle/app/oracle/oralhr/system01.dbfchannel ORA_DISK_1: starting piece 1 at 2016-04-11 14:31:42channel ORA_DISK_1: finished piece 1 at 2016-04-11 14:31:45piece handle=/oracle/app/oracle/ORALHR/backupset/2016_04_11/o1_mf_nnndf_TAG20160411T143142_cjpk6gt0_.bkp tag=TAG20160411T143142 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:03channel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setincluding current control file in backup setincluding current SPFILE in backup setchannel ORA_DISK_1: starting piece 1 at 2016-04-11 14:31:46channel ORA_DISK_1: finished piece 1 at 2016-04-11 14:31:47piece handle=/oracle/app/oracle/ORALHR/backupset/2016_04_11/o1_mf_ncsnf_TAG20160411T143142_cjpk6lwq_.bkp tag=TAG20160411T143142 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 2016-04-11 14:31:47RMAN> list backup of datafile 1;using target database control file instead of recovery catalogList of Backup Sets===================BS Key Type LV Size Device Type Elapsed Time Completion Time——- —- — ———- ———– ———— ——————-45 Full 657.98M DISK 00:00:03 2016-04-11 14:31:45 BP Key: 45 Status: AVAILABLE Compressed: NO Tag: TAG20160411T143142 Piece Name: /oracle/app/oracle/ORALHR/backupset/2016_04_11/o1_mf_nnndf_TAG20160411T143142_cjpk6gt0_.bkp List of Datafiles in backup set 45 File LV Type Ckp SCN Ckp Time Name —- — —- ———- ——————- —- 1 Full 1283795 2016-04-11 14:31:42 /oracle/app/oracle/oralhr/system01.dbfRMAN>RMAN> exitRecovery Manager complete.[ZHLHRDB2:oracle]:/home/oracle>新建一个表t_lhr_20160411_02,每次插入一条数据,然后每3次insert操作后执行一次switch logfile的操作,保证每个归档文件里有3条insert的操作记录:[ZHLHRDB2:oracle]:/home/oracle>sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Mon Apr 11 14:36:12 2016Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit ProductionWith the Partitioning, Real Application Clusters, OLAP, Data Miningand Real Application Testing optionsSYS@oralhr> archive log list;Database log mode Archive ModeAutomatic archival EnabledArchive destination USE_DB_RECOVERY_FILE_DESTOldest online log sequence 44Next log sequence to archive 46Current log sequence 46SYS@oralhr> show parameter DB_RECOVERY_FILE_DESTNAME TYPE VALUE———————————— ———————- ——————————db_recovery_file_dest string /oracle/app/oracledb_recovery_file_dest_size big integer 4182MSYS@oralhr> col status for a10SYS@oralhr> select GROUP# ,SEQUENCE#,STATUS,FIRST_CHANGE#,FIRST_TIME from v$log; GROUP# SEQUENCE# STATUS FIRST_CHANGE# FIRST_TIME———- ———- ———- ————- ——————- 1 46 CURRENT 1282753 2016-04-11 13:55:44 2 44 INACTIVE 1282665 2016-04-11 13:55:01 3 45 INACTIVE 1282745 2016-04-11 13:55:44SYS@oralhr>SYS@oralhr> alter system switch logfile;System altered.SYS@oralhr> select GROUP# ,SEQUENCE#,STATUS,FIRST_CHANGE#,FIRST_TIME from v$log; GROUP# SEQUENCE# STATUS FIRST_CHANGE# FIRST_TIME———- ———- ———- ————- ——————- 1 46 ACTIVE 1282753 2016-04-11 13:55:44 2 47 CURRENT 1283935 2016-04-11 14:37:10 3 45 INACTIVE 1282745 2016-04-11 13:55:44====》 当前日志序列是47号,47号我们建表和插入3条数据:SYS@oralhr> create table t_lhr_20160411_02(id number);Table created.SYS@oralhr> insert into t_lhr_20160411_02 values(1);1 row created.SYS@oralhr>SYS@oralhr> insert into t_lhr_20160411_02 values(2);1 row created.SYS@oralhr> insert into t_lhr_20160411_02 values(3);1 row created.SYS@oralhr> commit;Commit complete.SYS@oralhr> alter system switch logfile;System altered.====》 当前日志序列是48号,48号我们插入3条数据:SYS@oralhr> select GROUP# ,SEQUENCE#,STATUS,FIRST_CHANGE#,FIRST_TIME from v$log; GROUP# SEQUENCE# STATUS FIRST_CHANGE# FIRST_TIME———- ———- ———- ————- ——————- 1 46 ACTIVE 1282753 2016-04-11 13:55:44 2 47 ACTIVE 1283935 2016-04-11 14:37:10 3 48 CURRENT 1284002 2016-04-11 14:39:47SYS@oralhr> insert into t_lhr_20160411_02 values(4);1 row created.SYS@oralhr> insert into t_lhr_20160411_02 values(5);1 row created.SYS@oralhr> insert into t_lhr_20160411_02 values(6);1 row created.SYS@oralhr> commit;Commit complete.SYS@oralhr> alter system switch logfile;System altered.====》 当前日志序列是49号,49号我们插入3条数据:SYS@oralhr> select GROUP# ,SEQUENCE#,STATUS,FIRST_CHANGE#,FIRST_TIME from v$log; GROUP# SEQUENCE# STATUS FIRST_CHANGE# FIRST_TIME———- ———- ———- ————- ——————- 1 49 CURRENT 1284016 2016-04-11 14:40:18 2 47 ACTIVE 1283935 2016-04-11 14:37:10 3 48 ACTIVE 1284002 2016-04-11 14:39:47SYS@oralhr> insert into t_lhr_20160411_02 values(7);1 row created.SYS@oralhr> insert into t_lhr_20160411_02 values(8);1 row created.SYS@oralhr> insert into t_lhr_20160411_02 values(9);1 row created.SYS@oralhr> commit;Commit complete.SYS@oralhr> alter system switch logfile;System altered.====》建表操作在47号日志,47,48,49分别插入了3条记录,t_lhr_20160411_02共9条记录SYS@oralhr> select GROUP# ,SEQUENCE#,STATUS,FIRST_CHANGE#,FIRST_TIME from v$log; GROUP# SEQUENCE# STATUS FIRST_CHANGE# FIRST_TIME———- ———- ———- ————- ——————- 1 49 ACTIVE 1284016 2016-04-11 14:40:18 2 50 CURRENT 1284034 2016-04-11 14:40:54 3 48 ACTIVE 1284002 2016-04-11 14:39:47SYS@oralhr> select count(1) from t_lhr_20160411_02; COUNT(1)———- 9SYS@oralhr>SYS@oralhr> select name from v$datafile;NAME——————————————————————–/oracle/app/oracle/oralhr/system01.dbf/oracle/app/oracle/oralhr/sysaux01.dbf/oracle/app/oracle/oralhr/undotbs01.dbf/oracle/app/oracle/oralhr/users01.dbf/oracle/app/oracle/oralhr/example01.dbf====》删除1号文件SYS@oralhr> ! rm /oracle/app/oracle/oralhr/system01.dbfSYS@oralhr> alter system switch logfile;System altered.SYS@oralhr>SYS@oralhr> alter system switch logfile;System altered.SYS@oralhr> alter system switch logfile;System altered.SYS@oralhr> select GROUP# ,SEQUENCE#,STATUS,FIRST_CHANGE#,FIRST_TIME from v$log; GROUP# SEQUENCE# STATUS FIRST_CHANGE# FIRST_TIME———- ———- ———- ————- ——————- 1 52 INACTIVE 1284103 2016-04-11 14:43:48 2 53 CURRENT 1284106 2016-04-11 14:43:51 3 51 INACTIVE 1284100 2016-04-11 14:43:45====》53号日志插入一条记录,则t_lhr_20160411_02共10条记录SYS@oralhr> insert into t_lhr_20160411_02 values(10);1 row created.SYS@oralhr> commit;Commit complete.SYS@oralhr> select count(1) from t_lhr_20160411_02; COUNT(1)———- 10SYS@oralhr> alter system switch logfile;System altered.SYS@oralhr> alter system flush buffer_cache;System altered.SYS@oralhr> select count(1) from dba_objects; COUNT(1)———- 86827SYS@oralhr> alter system flush buffer_cache;System altered.SYS@oralhr> alter system switch logfile;System altered.====》切换日志过程中有一定几率数据库down掉,若没有就shutdown abort掉,然后重启SYS@oralhr> select GROUP# ,SEQUENCE#,STATUS,FIRST_CHANGE#,FIRST_TIME from v$log; GROUP# SEQUENCE# STATUS FIRST_CHANGE# FIRST_TIME———- ———- ———- ————- ——————- 1 55 CURRENT 1284157 2016-04-11 14:46:06 2 53 INACTIVE 1284106 2016-04-11 14:43:51 3 54 INACTIVE 1284128 2016-04-11 14:44:51SYS@oralhr>SYS@oralhr> shutdown abortORACLE instance shut down.SYS@oralhr> startupORACLE instance started.Total System Global Area 3089920000 bytesFixed Size 2250360 bytesVariable Size 721422728 bytesDatabase Buffers 2348810240 bytesRedo Buffers 17436672 bytesDatabase mounted.ORA-01157: cannot identify/lock data file 1 – see DBWR trace fileORA-01110: data file 1: ‘/oracle/app/oracle/oralhr/system01.dbf’SYS@oralhr> col status for a10SYS@oralhr> select GROUP# ,SEQUENCE#,STATUS,FIRST_CHANGE#,FIRST_TIME from v$log; GROUP# SEQUENCE# STATUS FIRST_CHANGE# FIRST_TIME———- ———- ———- ————- ——————- 1 55 CURRENT 1284157 2016-04-11 14:46:06 3 54 INACTIVE 1284128 2016-04-11 14:44:51 2 53 INACTIVE 1284106 2016-04-11 14:43:51SYS@oralhr>SYS@oralhr> col name format a60SYS@oralhr> col ERROR format a30SYS@oralhr> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#—————— 1284157SYS@oralhr>SYS@oralhr> SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; FILE# NAME CHECKPOINT_CHANGE# LAST_CHANGE# STATUS———- ———————————————————— —————— ———— ———- 1 /oracle/app/oracle/oralhr/system01.dbf 1284157 SYSTEM 2 /oracle/app/oracle/oralhr/sysaux01.dbf 1284157 ONLINE 3 /oracle/app/oracle/oralhr/undotbs01.dbf 1284157 ONLINE 4 /oracle/app/oracle/oralhr/users01.dbf 1284157 ONLINE 5 /oracle/app/oracle/oralhr/example01.dbf 1284157 ONLINESYS@oralhr>SYS@oralhr> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME RECOVE CHECKPOINT_CHANGE# STATUS———- ———————————————————— —— —————— ———- 1 0 ONLINE 2 /oracle/app/oracle/oralhr/sysaux01.dbf NO 1284157 ONLINE 3 /oracle/app/oracle/oralhr/undotbs01.dbf NO 1284157 ONLINE 4 /oracle/app/oracle/oralhr/users01.dbf NO 1284157 ONLINE 5 /oracle/app/oracle/oralhr/example01.dbf NO 1284157 ONLINESYS@oralhr>SYS@oralhr> select file#,online_status,change#,ERROR from v$recover_file; FILE# ONLINE_STATUS CHANGE# ERROR———- ————– ———- —————————— 1 ONLINE 0 FILE NOT FOUNDSYS@oralhr>SYS@oralhr>====》可以看到1号数据文件找不到,然后我们删除48号归档,确保不能通过recover来恢复[ZHLHRDB2:oracle]:/oracle>rman target /Recovery Manager: Release 11.2.0.4.0 – Production on Mon Apr 11 14:55:39 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database: ORALHR (DBID=394957205, not open)RMAN> delete archivelog sequence 48;using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=97 device type=DISKList of Archived Log Copies for database with db_unique_name ORALHR=====================================================================Key Thrd Seq S Low Time——- —- ——- – ——————-100 1 48 A 2016-04-11 14:39:47 Name: /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_48_cjpkplfj_.arcDo you really want to delete the above objects (enter YES or NO)? YESdeleted archived logarchived log file name=/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_48_cjpkplfj_.arc RECID=100 STAMP=908894418Deleted 1 objectsRMAN>RMAN> list archivelog all;List of Archived Log Copies for database with db_unique_name ORALHR=====================================================================Key Thrd Seq S Low Time——- —- ——- – ——————-98 1 46 A 2016-04-11 13:55:44 Name: /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_46_cjpkjpd8_.arc99 1 47 A 2016-04-11 14:37:10 Name: /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_47_cjpkomvt_.arc101 1 49 A 2016-04-11 14:40:18 Name: /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_49_cjpkqpsh_.arc102 1 50 A 2016-04-11 14:40:54 Name: /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_50_cjpkx1ry_.arc103 1 51 A 2016-04-11 14:43:45 Name: /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_51_cjpkx4tg_.arc104 1 52 A 2016-04-11 14:43:48 Name: /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_52_cjpkx7tg_.arc105 1 53 A 2016-04-11 14:43:51 Name: /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_53_cjpkz30t_.arc106 1 54 A 2016-04-11 14:44:51 Name: /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_54_cjpl1g47_.arc接下来,我们通过rman来还原1号数据文件,由于归档丢失,不能recover,若非system,undo的数据文件,我们可以offline 掉,然后就可以打开数据库了,但是system必须online才能打开数据库,所以目前数据库不能打开:[ZHLHRDB2:oracle]:/oracle>rman target /Recovery Manager: Release 11.2.0.4.0 – Production on Mon Apr 11 14:58:16 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database: ORALHR (DBID=394957205, not open)RMAN> restore datafile 1;Starting restore at 2016-04-11 14:58:24using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=97 device type=DISKchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00001 to /oracle/app/oracle/oralhr/system01.dbfchannel ORA_DISK_1: reading from backup piece /oracle/app/oracle/ORALHR/backupset/2016_04_11/o1_mf_nnndf_TAG20160411T143142_cjpk6gt0_.bkpchannel ORA_DISK_1: piece handle=/oracle/app/oracle/ORALHR/backupset/2016_04_11/o1_mf_nnndf_TAG20160411T143142_cjpk6gt0_.bkp tag=TAG20160411T143142channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:07Finished restore at 2016-04-11 14:58:32RMAN> recover datafile 1;Starting recover at 2016-04-11 14:58:45using channel ORA_DISK_1starting media recoveryarchived log for thread 1 with sequence 46 is already on disk as file /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_46_cjpkjpd8_.arcarchived log for thread 1 with sequence 47 is already on disk as file /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_47_cjpkomvt_.arcarchived log for thread 1 with sequence 49 is already on disk as file /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_49_cjpkqpsh_.arcarchived log for thread 1 with sequence 50 is already on disk as file /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_50_cjpkx1ry_.arcarchived log for thread 1 with sequence 51 is already on disk as file /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_51_cjpkx4tg_.arcarchived log for thread 1 with sequence 52 is already on disk as file /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_52_cjpkx7tg_.arcarchived log for thread 1 with sequence 53 is already on disk as file /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_53_cjpkz30t_.arcarchived log for thread 1 with sequence 54 is already on disk as file /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_54_cjpl1g47_.arcRMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 04/11/2016 14:58:45RMAN-06053: unable to perform media recovery because of missing logRMAN-06025: no backup of archived log for thread 1 with sequence 48 and starting SCN of 1284002 found to restore====》 由于缺少48号日志不能完成recover操作,我们先将redo应用到48号RMAN> recover datafile 1 until sequence 48;Starting recover at 2016-04-11 14:59:20using channel ORA_DISK_1starting media recoveryarchived log for thread 1 with sequence 46 is already on disk as file /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_46_cjpkjpd8_.arcarchived log for thread 1 with sequence 47 is already on disk as file /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_47_cjpkomvt_.arcarchived log file name=/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_46_cjpkjpd8_.arc thread=1 sequence=46archived log file name=/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_47_cjpkomvt_.arc thread=1 sequence=47media recovery complete, elapsed time: 00:00:00Finished recover at 2016-04-11 14:59:20RMAN>可以看到由于48号归档丢失,不能完成recover操作。[ZHLHRDB2:oracle]:/oracle>sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Mon Apr 11 15:06:12 2016Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit ProductionWith the Partitioning, Real Application Clusters, OLAP, Data Miningand Real Application Testing optionsSYS@oralhr> col name for a80SYS@oralhr> set linesize 9999 pagesize 9999SYS@oralhr> col FIRST_CHANGE# for 999999999999999SYS@oralhr> SELECT NAME, 2 sequence#, 3 a.FIRST_CHANGE# 4 FROM v$archived_log a 5 WHERE resetlogs_change# = (SELECT d.RESETLOGS_CHANGE# FROM v$database d) 6 AND a.sequence# >=45 7 ORDER BY a.sequence#;NAME SEQUENCE# FIRST_CHANGE#——————————————————————————– ———- —————- 45 1282745/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_46_cjpkjpd8_.arc 46 1282753/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_47_cjpkomvt_.arc 47 1283935 48 1284002/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_49_cjpkqpsh_.arc 49 1284016/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_50_cjpkx1ry_.arc 50 1284034/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_51_cjpkx4tg_.arc 51 1284100/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_52_cjpkx7tg_.arc 52 1284103/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_53_cjpkz30t_.arc 53 1284106/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_54_cjpl1g47_.arc 54 128412810 rows selected.SYS@oralhr>SYS@oralhr> col status for a10SYS@oralhr> select GROUP# ,SEQUENCE#,STATUS,FIRST_CHANGE#,FIRST_TIME from v$log; GROUP# SEQUENCE# STATUS FIRST_CHANGE# FIRST_TIME———- ———- ———- —————- ——————- 1 55 CURRENT 1284157 2016-04-11 14:46:06 3 54 INACTIVE 1284128 2016-04-11 14:44:51 2 53 INACTIVE 1284106 2016-04-11 14:43:51SYS@oralhr>SYS@oralhr> col name format a60SYS@oralhr> col ERROR format a30SYS@oralhr> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#—————— 1284157SYS@oralhr> SELECT a.FILE#, a.NAME,a.CHECKPOINT_CHANGE#,a.LAST_CHANGE#,status FROM v$datafile a; FILE# NAME CHECKPOINT_CHANGE# LAST_CHANGE# STATUS———- ———————————————————— —————— ———— ———- 1 /oracle/app/oracle/oralhr/system01.dbf 1284157 SYSTEM 2 /oracle/app/oracle/oralhr/sysaux01.dbf 1284157 ONLINE 3 /oracle/app/oracle/oralhr/undotbs01.dbf 1284157 ONLINE 4 /oracle/app/oracle/oralhr/users01.dbf 1284157 ONLINE 5 /oracle/app/oracle/oralhr/example01.dbf 1284157 ONLINESYS@oralhr>SYS@oralhr> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME RECOVE CHECKPOINT_CHANGE# STATUS———- ———————————————————— —— —————— ———- 1 /oracle/app/oracle/oralhr/system01.dbf YES 1284002 ONLINE 2 /oracle/app/oracle/oralhr/sysaux01.dbf NO 1284157 ONLINE 3 /oracle/app/oracle/oralhr/undotbs01.dbf NO 1284157 ONLINE 4 /oracle/app/oracle/oralhr/users01.dbf NO 1284157 ONLINE 5 /oracle/app/oracle/oralhr/example01.dbf NO 1284157 ONLINESYS@oralhr> select file#,online_status,change#,ERROR from v$recover_file; FILE# ONLINE_STATUS CHANGE# ERROR———- ————– ———- —————————— 1 ONLINE 1284002SYS@oralhr>SYS@oralhr>====》转换为十六进制SYS@oralhr> select to_char(1284002,’xxxxxxxx’) cur_scn,to_char(1284016,’xxxxxxxx’) target_scn,to_char(49,’xxxxxxxx’) target_seq from dual;CUR_SCN TARGET_SCN TARGET_SEQ—————— —————— —————— 1397a2 1397b0 31SYS@oralhr>====》 可以看到日志应用到了48号日志的开头,接下来利用bbed来跳过48号,从49号的开头开始恢复====》我们只能先让redo应用到48号日志,下边通过BBED来跳过48号,继续恢复应用49及后边的日志:[ZHLHRDB2:oracle]:/home/oracle>ltotal 112-rw-r–r– 1 oracle dba 57 Apr 05 17:01 bbed.par-rw-r–r– 1 oracle dba 17408 Apr 11 11:38 bifile.bbd-rw-r–r– 1 oracle asmadmin 5715 Apr 06 15:34 ctl.sql-rw-r–r– 1 oracle dba 253 Apr 05 17:00 file.txt-rw-r–r– 1 oracle dba 10536 Apr 11 15:02 log.bbddrwxr-xr-x 3 oracle dba 256 Apr 08 11:02 oracle_bkdrwxr-xr-x 4 oracle dba 256 Apr 05 16:54 rman_bak-rw-r–r– 1 oracle dba 757 Apr 11 10:02 rman_bk_db_archive_lhr.sh-rw-r–r– 1 oracle dba 1023 Apr 08 11:25 rman_bk_db_lhr.sh[ZHLHRDB2:oracle]:/home/oracle>cat bbed.parblocksize=8192listfile=/home/oracle/file.txtmode=edit[ZHLHRDB2:oracle]:/home/oracle>cat file.txt1 /oracle/app/oracle/oralhr/system01.dbf 7864320002 /oracle/app/oracle/oralhr/sysaux01.dbf 5138022403 /oracle/app/oracle/oralhr/undotbs01.dbf 943718404 /oracle/app/oracle/oralhr/users01.dbf 52428805 /oracle/app/oracle/oralhr/example01.dbf 328335360[ZHLHRDB2:oracle]:/home/oracle>bbed parfile=bbed.par[ZHLHRDB2:oracle]:/home/oracle>bbed parfile=bbed.parPassword:BBED: Release 2.0.0.0.0 – Limited Production on Mon Apr 11 15:02:46 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.************* !!! For Oracle Internal Use only !!! ***************BBED> infoFile# Name Size(blks)—– —- ———- 1 /oracle/app/oracle/oralhr/system01.dbf 96000 2 /oracle/app/oracle/oralhr/sysaux01.dbf 62720 3 /oracle/app/oracle/oralhr/undotbs01.dbf 11520 4 /oracle/app/oracle/oralhr/users01.dbf 640 5 /oracle/app/oracle/oralhr/example01.dbf 40080BBED> show FILE# 1 BLOCK# 1 OFFSET 0 DBA 0x00400001 (4194305 1,1) FILENAME /oracle/app/oracle/oralhr/system01.dbf BIFILE bifile.bbd LISTFILE /home/oracle/file.txt BLOCKSIZE 8192 MODE Edit EDIT Unrecoverable IBASE Dec OBASE Dec WIDTH 80 COUNT 512 LOGFILE log.bbd SPOOL NoBBED> p kcvfhckpstruct kcvfhckp, 160 bytes @484 struct kcvcpscn, 8 bytes @484 ub4 kscnbas @484 0x001397a2 ub2 kscnwrp @488 0x0000 ub4 kcvcptim @492 0x362ca0b3 ub2 kcvcpthr @496 0x0001 union u, 12 bytes @500 struct kcvcprba, 12 bytes @500 ub4 kcrbaseq @500 0x00000030 ub4 kcrbabno @504 0x00000002 ub2 kcrbabof @508 0x0000 ub1 kcvcpetb[0] @512 0x02 ub1 kcvcpetb[1] @513 0x00 ub1 kcvcpetb[2] @514 0x00 ub1 kcvcpetb[3] @515 0x00 ub1 kcvcpetb[4] @516 0x00 ub1 kcvcpetb[5] @517 0x00 ub1 kcvcpetb[6] @518 0x00 ub1 kcvcpetb[7] @519 0x00 ub1 kcvcpetb[8] @520 0x00 ub1 kcvcpetb[9] @521 0x00 ub1 kcvcpetb[10] @522 0x00 ub1 kcvcpetb[11] @523 0x00 ub1 kcvcpetb[12] @524 0x00 ub1 kcvcpetb[13] @525 0x00 ub1 kcvcpetb[14] @526 0x00 ub1 kcvcpetb[15] @527 0x00 ub1 kcvcpetb[16] @528 0x00 ub1 kcvcpetb[17] @529 0x00 ub1 kcvcpetb[18] @530 0x00 ub1 kcvcpetb[19] @531 0x00 ub1 kcvcpetb[20] @532 0x00 ub1 kcvcpetb[21] @533 0x00 ub1 kcvcpetb[22] @534 0x00 ub1 kcvcpetb[23] @535 0x00 ub1 kcvcpetb[24] @536 0x00 ub1 kcvcpetb[25] @537 0x00 ub1 kcvcpetb[26] @538 0x00 ub1 kcvcpetb[27] @539 0x00 ub1 kcvcpetb[28] @540 0x00 ub1 kcvcpetb[29] @541 0x00 ub1 kcvcpetb[30] @542 0x00 ub1 kcvcpetb[31] @543 0x00 ub1 kcvcpetb[32] @544 0x00 ub1 kcvcpetb[33] @545 0x00 ub1 kcvcpetb[34] @546 0x00 ub1 kcvcpetb[35] @547 0x00 ub1 kcvcpetb[36] @548 0x00 ub1 kcvcpetb[37] @549 0x00 ub1 kcvcpetb[38] @550 0x00 ub1 kcvcpetb[39] @551 0x00 ub1 kcvcpetb[40] @552 0x00 ub1 kcvcpetb[41] @553 0x00 ub1 kcvcpetb[42] @554 0x00 ub1 kcvcpetb[43] @555 0x00 ub1 kcvcpetb[44] @556 0x00 ub1 kcvcpetb[45] @557 0x00 ub1 kcvcpetb[46] @558 0x00 ub1 kcvcpetb[47] @559 0x00 ub1 kcvcpetb[48] @560 0x00 ub1 kcvcpetb[49] @561 0x00 ub1 kcvcpetb[50] @562 0x00 ub1 kcvcpetb[51] @563 0x00 ub1 kcvcpetb[52] @564 0x00 ub1 kcvcpetb[53] @565 0x00 ub1 kcvcpetb[54] @566 0x00 ub1 kcvcpetb[55] @567 0x00 ub1 kcvcpetb[56] @568 0x00 ub1 kcvcpetb[57] @569 0x00 ub1 kcvcpetb[58] @570 0x00 ub1 kcvcpetb[59] @571 0x00 ub1 kcvcpetb[60] @572 0x00 ub1 kcvcpetb[61] @573 0x00 ub1 kcvcpetb[62] @574 0x00 ub1 kcvcpetb[63] @575 0x00 ub1 kcvcpetb[64] @576 0x00 ub1 kcvcpetb[65] @577 0x00 ub1 kcvcpetb[66] @578 0x00 ub1 kcvcpetb[67] @579 0x00 ub1 kcvcpetb[68] @580 0x00 ub1 kcvcpetb[69] @581 0x00 ub1 kcvcpetb[70] @582 0x00 ub1 kcvcpetb[71] @583 0x00 ub1 kcvcpetb[72] @584 0x00 ub1 kcvcpetb[73] @585 0x00 ub1 kcvcpetb[74] @586 0x00 ub1 kcvcpetb[75] @587 0x00 ub1 kcvcpetb[76] @588 0x00 ub1 kcvcpetb[77] @589 0x00 ub1 kcvcpetb[78] @590 0x00 ub1 kcvcpetb[79] @591 0x00 ub1 kcvcpetb[80] @592 0x00 ub1 kcvcpetb[81] @593 0x00 ub1 kcvcpetb[82] @594 0x00 ub1 kcvcpetb[83] @595 0x00 ub1 kcvcpetb[84] @596 0x00 ub1 kcvcpetb[85] @597 0x00 ub1 kcvcpetb[86] @598 0x00 ub1 kcvcpetb[87] @599 0x00 ub1 kcvcpetb[88] @600 0x00 ub1 kcvcpetb[89] @601 0x00 ub1 kcvcpetb[90] @602 0x00 ub1 kcvcpetb[91] @603 0x00 ub1 kcvcpetb[92] @604 0x00 ub1 kcvcpetb[93] @605 0x00 ub1 kcvcpetb[94] @606 0x00 ub1 kcvcpetb[95] @607 0x00 ub1 kcvcpetb[96] @608 0x00 ub1 kcvcpetb[97] @609 0x00 ub1 kcvcpetb[98] @610 0x00 ub1 kcvcpetb[99] @611 0x00 ub1 kcvcpetb[100] @612 0x00 ub1 kcvcpetb[101] @613 0x00 ub1 kcvcpetb[102] @614 0x00 ub1 kcvcpetb[103] @615 0x00 ub1 kcvcpetb[104] @616 0x00 ub1 kcvcpetb[105] @617 0x00 ub1 kcvcpetb[106] @618 0x00 ub1 kcvcpetb[107] @619 0x00 ub1 kcvcpetb[108] @620 0x00 ub1 kcvcpetb[109] @621 0x00 ub1 kcvcpetb[110] @622 0x00 ub1 kcvcpetb[111] @623 0x00 ub1 kcvcpetb[112] @624 0x00 ub1 kcvcpetb[113] @625 0x00 ub1 kcvcpetb[114] @626 0x00 ub1 kcvcpetb[115] @627 0x00 ub1 kcvcpetb[116] @628 0x00 ub1 kcvcpetb[117] @629 0x00 ub1 kcvcpetb[118] @630 0x00 ub1 kcvcpetb[119] @631 0x00 ub1 kcvcpetb[120] @632 0x00 ub1 kcvcpetb[121] @633 0x00 ub1 kcvcpetb[122] @634 0x00 ub1 kcvcpetb[123] @635 0x00 ub1 kcvcpetb[124] @636 0x00 ub1 kcvcpetb[125] @637 0x00 ub1 kcvcpetb[126] @638 0x00 ub1 kcvcpetb[127] @639 0x00 ub1 kcvcpetb[128] @640 0x00====》数据文件的scn被记录在文件1号block偏移量484字节开始的四个字节中BBED> d /v dba 1,1 offset 484 count 64File: /oracle/app/oracle/oralhr/system01.dbf (1)Block: 1 Offsets: 484 to 547 Dba:0x00400001——————————————————-001397a2 0000c828 362ca0b3 00010000 l …….(6,……00000030 00000002 00000000 02000000 l …0…………00000000 00000000 00000000 00000000 l …………….00000000 00000000 00000000 00000000 l …………….====》AIX下存储是正序,这个和linux正好相反BBED> modify /x 001397b0 dba 1,1 offset 484Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) YFile: /oracle/app/oracle/oralhr/system01.dbf (1)Block: 1 Offsets: 484 to 547 Dba:0x00400001————————————————————————001397b0 0000c828 362ca0b3 00010000 00000030 00000002 00000000 0200000000000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000BBED> sum applyCheck value for File 1, Block 1:current = 0x0065, required = 0x0065BBED> d /v dba 1,1 offset 484 count 64File: /oracle/app/oracle/oralhr/system01.dbf (1)Block: 1 Offsets: 484 to 547 Dba:0x00400001——————————————————-001397b0 0000c828 362ca0b3 00010000 l …….(6,……00000030 00000002 00000000 02000000 l …0…………00000000 00000000 00000000 00000000 l …………….00000000 00000000 00000000 00000000 l …………….BBED>SYS@oralhr> col name for a80SYS@oralhr> set linesize 9999 pagesize 9999SYS@oralhr> col FIRST_CHANGE# for 999999999999999SYS@oralhr> SELECT NAME, 2 sequence#, 3 a.FIRST_CHANGE# 4 FROM v$archived_log a 5 WHERE resetlogs_change# = (SELECT d.RESETLOGS_CHANGE# FROM v$database d) 6 AND a.sequence# =49 7 ORDER BY a.sequence#;NAME SEQUENCE# FIRST_CHANGE#——————————————————————————– ———- —————-/oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_49_cjpkqpsh_.arc 49 1284016SYS@oralhr> SELECT a.FILE#,a.NAME,a.RECOVER,a.CHECKPOINT_CHANGE#,status FROM v$datafile_header a; FILE# NAME RECOVE CHECKPOINT_CHANGE# STATUS———- ——————————————————————————– —— —————— ———- 1 /oracle/app/oracle/oralhr/system01.dbf YES 1284016 ONLINE 2 /oracle/app/oracle/oralhr/sysaux01.dbf NO 1284157 ONLINE 3 /oracle/app/oracle/oralhr/undotbs01.dbf NO 1284157 ONLINE 4 /oracle/app/oracle/oralhr/users01.dbf NO 1284157 ONLINE 5 /oracle/app/oracle/oralhr/example01.dbf NO 1284157 ONLINESYS@oralhr>BBED> d /v dba 1,1 offset 500 count 64File: /oracle/app/oracle/oralhr/system01.dbf (1)Block: 1 Offsets: 500 to 563 Dba:0x00400001——————————————————-00000030 00000002 00000000 02000000 l …0…………00000000 00000000 00000000 00000000 l …………….00000000 00000000 00000000 00000000 l …………….00000000 00000000 00000000 00000000 l …………….====》要想跳过归档还需要数据文件头块的rba。它由seq#、log block#、偏移量(固定为16)组成,决定了数据文件从哪个归档日志的哪个位置开始应用归档。Rba位于数据文件头块偏移量500处开始连续的12个字节BBED> modify /x 00000031 dba 1,1 offset 500File: /oracle/app/oracle/oralhr/system01.dbf (1)Block: 1 Offsets: 500 to 563 Dba:0x00400001————————————————————————00000031 00000002 00000000 02000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000BBED> sum applyCheck value for File 1, Block 1:current = 0x0064, required = 0x0064BBED> modify /x 00000010 dba 1,1 offset 508File: /oracle/app/oracle/oralhr/system01.dbf (1)Block: 1 Offsets: 508 to 571 Dba:0x00400001————————————————————————00000010 02000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000BBED>BBED> sum applyCheck value for File 1, Block 1:current = 0x0074, required = 0x0074BBED> d /v dba 1,1 offset 500 count 64File: /oracle/app/oracle/oralhr/system01.dbf (1)Block: 1 Offsets: 500 to 563 Dba:0x00400001——————————————————-00000031 00000002 00000010 02000000 l …1…………00000000 00000000 00000000 00000000 l …………….00000000 00000000 00000000 00000000 l …………….00000000 00000000 00000000 00000000 l …………….BBED> p kcvfhckpstruct kcvfhckp, 160 bytes @484 struct kcvcpscn, 8 bytes @484 ub4 kscnbas @484 0x001397b0 ub2 kscnwrp @488 0x0000 ub4 kcvcptim @492 0x362ca0b3 ub2 kcvcpthr @496 0x0001 union u, 12 bytes @500 struct kcvcprba, 12 bytes @500 ub4 kcrbaseq @500 0x00000031 ub4 kcrbabno @504 0x00000002 ub2 kcrbabof @508 0x0000 ub1 kcvcpetb[0] @512 0x02 ub1 kcvcpetb[1] @513 0x00 ub1 kcvcpetb[2] @514 0x00 ub1 kcvcpetb[3] @515 0x00 ub1 kcvcpetb[4] @516 0x00 ub1 kcvcpetb[5] @517 0x00 ub1 kcvcpetb[6] @518 0x00 ub1 kcvcpetb[7] @519 0x00 ub1 kcvcpetb[8] @520 0x00 ub1 kcvcpetb[9] @521 0x00 ub1 kcvcpetb[10] @522 0x00 ub1 kcvcpetb[11] @523 0x00 ub1 kcvcpetb[12] @524 0x00 ub1 kcvcpetb[13] @525 0x00 ub1 kcvcpetb[14] @526 0x00 ub1 kcvcpetb[15] @527 0x00 ub1 kcvcpetb[16] @528 0x00 ub1 kcvcpetb[17] @529 0x00 ub1 kcvcpetb[18] @530 0x00 ub1 kcvcpetb[19] @531 0x00 ub1 kcvcpetb[20] @532 0x00 ub1 kcvcpetb[21] @533 0x00 ub1 kcvcpetb[22] @534 0x00 ub1 kcvcpetb[23] @535 0x00 ub1 kcvcpetb[24] @536 0x00 ub1 kcvcpetb[25] @537 0x00 ub1 kcvcpetb[26] @538 0x00 ub1 kcvcpetb[27] @539 0x00 ub1 kcvcpetb[28] @540 0x00 ub1 kcvcpetb[29] @541 0x00 ub1 kcvcpetb[30] @542 0x00 ub1 kcvcpetb[31] @543 0x00 ub1 kcvcpetb[32] @544 0x00 ub1 kcvcpetb[33] @545 0x00 ub1 kcvcpetb[34] @546 0x00 ub1 kcvcpetb[35] @547 0x00 ub1 kcvcpetb[36] @548 0x00 ub1 kcvcpetb[37] @549 0x00 ub1 kcvcpetb[38] @550 0x00 ub1 kcvcpetb[39] @551 0x00 ub1 kcvcpetb[40] @552 0x00 ub1 kcvcpetb[41] @553 0x00 ub1 kcvcpetb[42] @554 0x00 ub1 kcvcpetb[43] @555 0x00 ub1 kcvcpetb[44] @556 0x00 ub1 kcvcpetb[45] @557 0x00 ub1 kcvcpetb[46] @558 0x00 ub1 kcvcpetb[47] @559 0x00 ub1 kcvcpetb[48] @560 0x00 ub1 kcvcpetb[49] @561 0x00 ub1 kcvcpetb[50] @562 0x00 ub1 kcvcpetb[51] @563 0x00 ub1 kcvcpetb[52] @564 0x00 ub1 kcvcpetb[53] @565 0x00 ub1 kcvcpetb[54] @566 0x00 ub1 kcvcpetb[55] @567 0x00 ub1 kcvcpetb[56] @568 0x00 ub1 kcvcpetb[57] @569 0x00 ub1 kcvcpetb[58] @570 0x00 ub1 kcvcpetb[59] @571 0x00 ub1 kcvcpetb[60] @572 0x00 ub1 kcvcpetb[61] @573 0x00 ub1 kcvcpetb[62] @574 0x00 ub1 kcvcpetb[63] @575 0x00 ub1 kcvcpetb[64] @576 0x00 ub1 kcvcpetb[65] @577 0x00 ub1 kcvcpetb[66] @578 0x00 ub1 kcvcpetb[67] @579 0x00 ub1 kcvcpetb[68] @580 0x00 ub1 kcvcpetb[69] @581 0x00 ub1 kcvcpetb[70] @582 0x00 ub1 kcvcpetb[71] @583 0x00 ub1 kcvcpetb[72] @584 0x00 ub1 kcvcpetb[73] @585 0x00 ub1 kcvcpetb[74] @586 0x00 ub1 kcvcpetb[75] @587 0x00 ub1 kcvcpetb[76] @588 0x00 ub1 kcvcpetb[77] @589 0x00 ub1 kcvcpetb[78] @590 0x00 ub1 kcvcpetb[79] @591 0x00 ub1 kcvcpetb[80] @592 0x00 ub1 kcvcpetb[81] @593 0x00 ub1 kcvcpetb[82] @594 0x00 ub1 kcvcpetb[83] @595 0x00 ub1 kcvcpetb[84] @596 0x00 ub1 kcvcpetb[85] @597 0x00 ub1 kcvcpetb[86] @598 0x00 ub1 kcvcpetb[87] @599 0x00 ub1 kcvcpetb[88] @600 0x00 ub1 kcvcpetb[89] @601 0x00 ub1 kcvcpetb[90] @602 0x00 ub1 kcvcpetb[91] @603 0x00 ub1 kcvcpetb[92] @604 0x00 ub1 kcvcpetb[93] @605 0x00 ub1 kcvcpetb[94] @606 0x00 ub1 kcvcpetb[95] @607 0x00 ub1 kcvcpetb[96] @608 0x00 ub1 kcvcpetb[97] @609 0x00 ub1 kcvcpetb[98] @610 0x00 ub1 kcvcpetb[99] @611 0x00 ub1 kcvcpetb[100] @612 0x00 ub1 kcvcpetb[101] @613 0x00 ub1 kcvcpetb[102] @614 0x00 ub1 kcvcpetb[103] @615 0x00 ub1 kcvcpetb[104] @616 0x00 ub1 kcvcpetb[105] @617 0x00 ub1 kcvcpetb[106] @618 0x00 ub1 kcvcpetb[107] @619 0x00 ub1 kcvcpetb[108] @620 0x00 ub1 kcvcpetb[109] @621 0x00 ub1 kcvcpetb[110] @622 0x00 ub1 kcvcpetb[111] @623 0x00 ub1 kcvcpetb[112] @624 0x00 ub1 kcvcpetb[113] @625 0x00 ub1 kcvcpetb[114] @626 0x00 ub1 kcvcpetb[115] @627 0x00 ub1 kcvcpetb[116] @628 0x00 ub1 kcvcpetb[117] @629 0x00 ub1 kcvcpetb[118] @630 0x00 ub1 kcvcpetb[119] @631 0x00 ub1 kcvcpetb[120] @632 0x00 ub1 kcvcpetb[121] @633 0x00 ub1 kcvcpetb[122] @634 0x00 ub1 kcvcpetb[123] @635 0x00 ub1 kcvcpetb[124] @636 0x00 ub1 kcvcpetb[125] @637 0x00 ub1 kcvcpetb[126] @638 0x00 ub1 kcvcpetb[127] @639 0x00 ub1 kcvcpetb[128] @640 0x00BBED>SYS@oralhr> recover datafile 1;ORA-00279: change 1284016 generated at 04/11/2016 14:39:47 needed for thread 1ORA-00289: suggestion : /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_49_cjpkqpsh_.arcORA-00280: change 1284016 for thread 1 is in sequence #49Specify log: {=suggested | filename | AUTO | CANCEL}autoORA-00279: change 1284034 generated at 04/11/2016 14:40:54 needed for thread 1ORA-00289: suggestion : /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_50_cjpkx1ry_.arcORA-00280: change 1284034 for thread 1 is in sequence #50ORA-00279: change 1284100 generated at 04/11/2016 14:43:45 needed for thread 1ORA-00289: suggestion : /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_51_cjpkx4tg_.arcORA-00280: change 1284100 for thread 1 is in sequence #51ORA-00279: change 1284103 generated at 04/11/2016 14:43:48 needed for thread 1ORA-00289: suggestion : /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_52_cjpkx7tg_.arcORA-00280: change 1284103 for thread 1 is in sequence #52Log applied.Media recovery complete.SYS@oralhr>SYS@oralhr> alter database open;Database altered.SYS@oralhr> select count(1) from t_lhr_20160411_02; COUNT(1)———- 7SYS@oralhr>====》 恢复完成,数据少了48号日志里的3条记录数据库正常打开。若归档文件只丢失了一部分,那么通过BBED修改文件头跳过丢失的归档日志,从而把所有还存在的归档日志apply掉,这样可以保证最小的数据丢失,所以碰到丢失归档的情况到底如何恢复还是得灵活运用。在实验过程中大家可以多模拟几种场景,比如只修改文件头offset484,不修改offset500的rda会出现什么问题,若是47号归档丢失(即建表的redo日志丢失),后续的redo apply会不会出现问题等等,都可以多思考然后做实验来证明,简单记录一下:SYS@oralhr> recover datafile 1;ORA-00279: change 1284016 generated at 04/11/2016 14:37:10 needed for thread 1ORA-00289: suggestion : /oracle/app/oracle/ORALHR/archivelog/2016_04_11/o1_mf_1_49_cjpkqpsh_.arcORA-00280: change 1284016 for thread 1 is in sequence #49Specify log: {=suggested | filename | AUTO | CANCEL}autoORA-00283: recovery session canceled due to errorsORA-10562: Error occurred while applying redo to data block (file# 1, block# 98185)ORA-10564: tablespace SYSTEMORA-01110: data file 1: ‘/oracle/app/oracle/oralhr/system01.dbf’ORA-10561: block type ‘TRANSACTION MANAGED DATA BLOCK’, data object# 88595ORA-00607: Internal error occurred while making a change to a data blockORA-00600: internal error code, arguments: [kdBlkCheckError], [1], [98185], [6110], [], [], [], [], [], [], [], []ORA-01112: media recovery not started解决办法:recover database using backup controlfile until cancel;alter database open resetlogs;若还是不能解决,就加如下的隐含参数:alter system set “_allow_resetlogs_corruption”=true scope=spfile;recover database using backup controlfile until cancel;alter database open resetlogs;startup forcealter database open resetlogs;alter system set “_allow_resetlogs_corruption”=false scope=spfile;alter system reset “_allow_resetlogs_corruption” scope=spfile sid=’*’;做完上边的实验后,我们要做的就是备份数据库,下边小麦苗给大家贡献2个基于归档和非归档的rman全备数据库的shell脚本,注意修改黄色背景的内容为自己的实际环境,其中非归档环境全备数据库需要重启到mount状态,也可以使用其他的热备脚本。注意修改黄色部分:export ORACLE_SID=ora11gexport ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1export PATH=$ORACLE_HOME/bin:$PATHMYDATE=`date +’%Y%m%d%H%M%S’`BACKUP_DIR=/home/oracle/oracle_bk/$ORACLE_SIDmkdir -p $BACKUP_DIR/logrman target / log $BACKUP_DIR/log/rman_full_$MYDATE.log append run{allocate channel c1 type disk;allocate channel c2 type disk;backup database filesperset 4 format ‘$BACKUP_DIR/full_%n_%T_%t_%s_%p.bak’;backup spfile tag=’bk_spfile_$MYDATE’ format=’$BACKUP_DIR/spfile_%n_%U_%T.bak’;sql ‘alter system archive log current’;backup archivelog all format ‘$BACKUP_DIR/arch_%d_%T_%s_%p.bak’ delete input;backup current controlfile format ‘$BACKUP_DIR/ctl_%d_%T_%s_%p.bak’;release channel c1;release channel c2;}EOFrman target / log $BACKUP_DIR/log/rman_delete_$MYDATE.log append allocate channel for maintenance type disk;allocate channel for maintenance type sbt_tape;crosscheck archivelog all;crosscheck backup;delete noprompt obsolete;EOF—————————– 非归档 mount 全备export ORACLE_SID=oralhrexport ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1export PATH=$ORACLE_HOME/bin:$PATHMYDATE=`date +’%Y%m%d%H%M%S’`BACKUP_DIR=/home/oracle/oracle_bk/$ORACLE_SIDmkdir -p $BACKUP_DIR/logrman target / log $BACKUP_DIR/log/rman_full_$MYDATE.log append run{shutdown immediate;startup mount;allocate channel c1 type disk;allocate channel c2 type disk;backup database filesperset 4 format ‘$BACKUP_DIR/full_%n_%T_%t_%s_%p.bak’;backup spfile tag=’bk_spfile_$MYDATE’ format=’$BACKUP_DIR/spfile_%n_%U_%T.bak’;backup archivelog all format ‘$BACKUP_DIR/arch_%d_%T_%s_%p.bak’ delete input;backup current controlfile format ‘$BACKUP_DIR/ctl_%d_%T_%s_%p.bak’;release channel c1;release channel c2;alter database open;}EOFrman target / log $BACKUP_DIR/log/rman_delete_$MYDATE.log append allocate channel for maintenance type disk;allocate channel for maintenance type sbt_tape;crosscheck archivelog all;crosscheck backup;delete noprompt obsolete;EOF看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注云技术行业资讯频道,感谢您对云技术的支持。

相关推荐: oracle中如何获取两天内的告警日志

这篇文章将为大家详细讲解有关oracle中如何获取两天内的告警日志,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。 #!/bin/bash#author: Rui Zhang#date: 2017-08-09#email: s…

文章页内容下
赞(0) 打赏
版权声明:本站采用知识共享、学习交流,不允许用于商业用途;文章由发布者自行承担一切责任,与本站无关。
文章页正文下
文章页评论上

云服务器、web空间可免费试用

宝塔面板主机、支持php,mysql等,SSL部署;安全高速企业专供99.999%稳定,另有高防主机、不限制内容等类型,具体可咨询QQ:360163164,Tel同微信:18905205712

主机选购导航云服务器试用

登录

找回密码

注册