归档文件丢失,数据库无法启动


--//第一种修复方式
alter database create datafile 7 as '/u01/app/oradata/QXY/tt.dbf'
创建datafile后,其scn是非常老的,需要进行recover,需要该scn应用后面所有的归档,但是数据文件被损坏的时候,数据基本上也是最新的,
并不需要从create_scn开始应用归档,这个时候可以通过bbed直接修改数据文件头,告诉recover datafile的时候从哪里开始应用归档


--//破坏数据文件头
BBED> copy file 6 block 5 to file 7 block 1
 File: /u01/app/oradata/QXY/tt.dbf (7)
 Block: 1                Offsets:    0 to   11           Dba:0x01c00001
------------------------------------------------------------------------
 1ea20000 05008001 e4851b00 

 <32 bytes per line>

BBED> sum apply
Check value for File 7, Block 1:
current = 0xc109, required = 0xc109

BBED> set dba 7,1
        DBA             0x01c00001 (29360129 7,1)

BBED> verify 
DBVERIFY - Verification starting
FILE = /u01/app/oradata/QXY/tt.dbf
BLOCK = 1

Block 1 is corrupt
Corrupt block relative dba: 0x01800001 (file 0, block 1)
Bad header found during verification
Data in bad block:
 type: 30 format: 2 rdba: 0x01800005
 last change scn: 0x0000.001b85e4 seq: 0x1 flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x85e41e01
 check value in block header: 0xc109
 computed block checksum: 0x0


DBVERIFY - Verification complete

Total Blocks Examined         : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing   (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 1
Total Blocks Influx           : 0
Message 531 not found;  product=RDBMS; facility=BBED


BBED> 

--//启动数据库
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup 
ORACLE instance started.

Total System Global Area  221331456 bytes
Fixed Size                  2251856 bytes
Variable Size             163578800 bytes
Database Buffers           50331648 bytes
Redo Buffers                5169152 bytes
Database mounted.
ORA-01122: database file 7 failed verification check
ORA-01110: data file 7: '/u01/app/oradata/QXY/tt.dbf'
ORA-01210: data file header is media corrupt


SQL> 


--//创建数据文件头
SQL> alter database create datafile 7 as '/u01/app/oradata/QXY/tt.dbf'
  2  ;

Database altered.

SQL> 

--//recover数据文件
SQL> recover datafile 7;
ORA-00279: change 2371076 generated at 09/21/2020 16:48:18 needed for thread 1  <=======需要的时间,其实就是数据文件刚创建的时间
ORA-00289: suggestion : /u01/app/fast_recovery_area/QXY/archivelog/2020_12_02/o1_mf_1_181_%u_.arc
ORA-00280: change 2371076 for thread 1 is in sequence #181


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log '/u01/app/fast_recovery_area/QXY/archivelog/2020_12_02/o1_mf_1_181_%u_.arc'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


ORA-00308: cannot open archived log '/u01/app/fast_recovery_area/QXY/archivelog/2020_12_02/o1_mf_1_181_%u_.arc'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


SQL> 

--//查看数据文件的create_time
SQL> select to_char(CREATION_TIME,'yyyy-mm-dd hh24:mi:ss'), file# from v$datafile;

TO_CHAR(CREATION_TI      FILE#
------------------- ----------
2013-08-24 11:37:33          1
2013-08-24 11:37:37          2
2013-08-24 12:07:19          3
2013-08-24 11:37:49          4
2020-07-15 17:11:46          5
2020-09-16 09:42:54          6
2020-09-21 16:48:18          7

7 rows selected.

SQL> 

--bbed修改恢复的起始时间和需要应用的归档号(归档号可以根据实际情况指定)
BBED> set dba 7,1
        DBA             0x01c00001 (29360129 7,1)

BBED> p kcvfhckp
struct kcvfhckp, 36 bytes                   @484     
   struct kcvcpscn, 8 bytes                 @484     
      ub4 kscnbas                           @484      0x00242e04   <====change#
      ub2 kscnwrp                           @488      0x0000
   ub4 kcvcptim                             @492      0x3eaffe52
   ub2 kcvcpthr                             @496      0x0001
   union u, 12 bytes                        @500     
      struct kcvcprba, 12 bytes             @500     
         ub4 kcrbaseq                       @500      0x000000b5   <====归档号
         ub4 kcrbabno                       @504      0x00008ec3
         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

BBED> 


--//查看归档
SQL> select SEQUENCE#,FIRST_TIME,NEXT_TIME,FIRST_CHANGE# ,NEXT_CHANGE#  from v$archived_log;

 SEQUENCE# FIRST_TIME         NEXT_TIME          FIRST_CHANGE# NEXT_CHANGE#
---------- ------------------ ------------------ ------------- ------------
       325 30-NOV-20          02-DEC-20                4318010      4343886
       326 02-DEC-20          02-DEC-20                4343886      4365001
       
--//修改归档号为326 ,change# 为4343886
SQL> 
SQL> select to_char(326,'xxxx') from dual;

TO_CH
-----
  146
SQL> 
SQL> select to_char(4343886,'xxxxxxxx') from dual;

TO_CHAR(4
---------
   42484e

SQL> 

--//bbed修改
BBED> set dba 7,1
        DBA             0x01c00001 (29360129 7,1)

BBED> p kcvfhckp
struct kcvfhckp, 36 bytes                   @484     
   struct kcvcpscn, 8 bytes                 @484     
      ub4 kscnbas                           @484      0x00242e04
      ub2 kscnwrp                           @488      0x0000
   ub4 kcvcptim                             @492      0x3eaffe52
   ub2 kcvcpthr                             @496      0x0001
   union u, 12 bytes                        @500     
      struct kcvcprba, 12 bytes             @500     
         ub4 kcrbaseq                       @500      0x000000b5
         ub4 kcrbabno                       @504      0x00008ec3
         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
BBED> set offset 500 
        OFFSET          500

BBED> d /v count 12
 File: /u01/app/oradata/QXY/tt.dbf (7)
 Block: 1       Offsets:  500 to  511  Dba:0x01c00001
-------------------------------------------------------
 b5000000 c38e0000 10000000          l ............

 <16 bytes per line>

BBED> m /x 4601
 File: /u01/app/oradata/QXY/tt.dbf (7)
 Block: 1                Offsets:  500 to  511           Dba:0x01c00001
------------------------------------------------------------------------
 46010000 c38e0000 10000000 

 <32 bytes per line>

BBED> set offset 484
        OFFSET          484

BBED> d /v count 12
 File: /u01/app/oradata/QXY/tt.dbf (7)
 Block: 1       Offsets:  484 to  495  Dba:0x01c00001
-------------------------------------------------------
 042e2400 00000000 52feaf3e          l ..$.....R..>

 <16 bytes per line>

BBED> m /x 4e4842
 File: /u01/app/oradata/QXY/tt.dbf (7)
 Block: 1                Offsets:  484 to  495           Dba:0x01c00001
------------------------------------------------------------------------
 4e484200 00000000 52feaf3e 

 <32 bytes per line>

BBED> sum apply
Check value for File 7, Block 1:
current = 0xc80e, required = 0xc80e

BBED> verify 
DBVERIFY - Verification starting
FILE = /u01/app/oradata/QXY/tt.dbf
BLOCK = 1


DBVERIFY - Verification complete

Total Blocks Examined         : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing   (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 0
Total Blocks Influx           : 0
Message 531 not found;  product=RDBMS; facility=BBED


BBED> 

--//恢复数据文件并启动数据库
SQL> recover datafile 7;
Media recovery complete.
SQL> alter database open;

Database altered.

SQL> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值