使用BBED跳過歸檔檔案

wailon發表於2013-11-10

[oracle@rhel5 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Mon May 20 15:45:37 2013

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>--檢視檔案號及SCN

SQL> select file#,checkpoint_change# from v$datafile_header;

     FILE# CHECKPOINT_CHANGE#

---------- ------------------

         1             823698

         2             823698

         3             823698

         5             823698

         6             823698

SQL> select file#,checkpoint_change# from v$datafile;

     FILE# CHECKPOINT_CHANGE#

---------- ------------------

         1             823698

         2             823698

         3             823698

         5             823698

         6             823698

SQL>--備份6號檔案

[oracle@rhel5 ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Mon May 20 15:47:52 2013

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: ORCL (DBID=1340950268)

RMAN> backup datafile 6;

Starting backup at 20-MAY-13

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=26 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00006 name=/u01/lost_it.dbf

channel ORA_DISK_1: starting piece 1 at 20-MAY-13

channel ORA_DISK_1: finished piece 1 at 20-MAY-13

piece handle=/u01/app/oracle/product/10.2.0/db_1/dbs/09oa48lk_1_1 tag=TAG20130520T154804 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 20-MAY-13

SQL>--切換日誌

SQL> alter system switch logfile;

System altered.

SQL>--離線6號檔案

SQL> alter database datafile 6 offline;

Database altered.

--還原6號檔案

RMAN> restore datafile 6;

Starting restore at 20-MAY-13

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00006 to /u01/lost_it.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/10.2.0/db_1/dbs/09oa48lk_1_1

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/app/oracle/product/10.2.0/db_1/dbs/09oa48lk_1_1 tag=TAG20130520T154804

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished restore at 20-MAY-13

RMAN>

SQL>--將檔案狀態切換為online時報錯,需要恢復

SQL> alter database datafile 6 online;

alter database datafile 6 online

*

ERROR at line 1:

ORA-01113: file 6 needs media recovery if it was restored from backup, or END

BACKUP if it was not

ORA-01110: data file 6: '/u01/lost_it.dbf'

SQL>--dump檔案頭

SQL> alter session set events 'immediate trace name file_hdrs level 10';

Session altered.

SQL> oradebug setmypid

Statement processed.

SQL> oradebug tracefile_name

/u01/app/admin/orcl/udump/orcl_ora_18761.trc

SQL>--檢視DUMP檔案

SQL> !vi /u01/app/admin/orcl/udump/orcl_ora_18761.trc

--SYSTEM表空間檔案

Tablespace #0 - SYSTEM  rel_fn:1

Creation   at   scn: 0x0000.00000006 04/19/2013 16:25:50

Backup taken at scn: 0x0000.00000000 01/01/1988 00:00:00 thread:0

reset logs count:0x30826fd4 scn: 0x0000.00091844 reset logs terminal rcv data:0x0 scn: 0x0000.00000000

prev reset logs count:0x30826bd8 scn: 0x0000.000915f0 prev reset logs terminal rcv data:0x0 scn: 0x0000.00000000

recovered at 04/28/2013 10:35:39

status:0x2004 root dba:0x00400179 chkpt cnt: 165 ctl cnt:164

begin-hot-backup file size: 0

Checkpointed at scn:  0x0000.000c91b405/20/2013 15:48:16

thread:1 rba:(0x2b.2.10)

--6號檔案

Tablespace #6 - LOST_IT  rel_fn:6

Creation   at   scn: 0x0000.00090e5d 04/27/2013 13:38:13

Backup taken at scn: 0x0000.00000000 01/01/1988 00:00:00 thread:0

reset logs count:0x30826fd4 scn: 0x0000.00091844 reset logs terminal rcv data:0x0 scn: 0x0000.00000000

prev reset logs count:0x30826bd8 scn: 0x0000.000915f0 prev reset logs terminal rcv data:0x0 scn: 0x0000.00000000

recovered at 05/20/2013 15:48:48

status:0x0 root dba:0x00000000 chkpt cnt: 105 ctl cnt:104

begin-hot-backup file size: 0

Checkpointed at scn:  0x0000.000c91ac05/20/2013 15:48:04

thread:1 rba:(0x2a.22078.10)

--注意SCNRBA的區別

SQL>--檢視剛剛切換的歸檔檔案

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

         1          1         43  104857600          1 NO  CURRENT                 823732 20-MAY-13

         2          1         41  104857600          1 YES INACTIVE                804855 20-MAY-13

         3          1         42  104857600          1 YES INACTIVE                813986 20-MAY-13

[oracle@rhel5 archlog]$ ll -tr

total 857576

-rw-r----- 1 oracle oinstall 100483072 May 20 07:59 1_34_813854676.dbf

-rw-r----- 1 oracle oinstall 100482048 May 20 08:19 1_35_813854676.dbf

-rw-r----- 1 oracle oinstall 100481536 May 20 11:25 1_36_813854676.dbf

-rw-r----- 1 oracle oinstall 100477440 May 20 11:25 1_37_813854676.dbf

-rw-r----- 1 oracle oinstall 100484096 May 20 11:26 1_38_813854676.dbf

-rw-r----- 1 oracle oinstall 100488192 May 20 11:27 1_39_813854676.dbf

-rw-r----- 1 oracle oinstall 100485120 May 20 11:28 1_40_813854676.dbf

-rw-r----- 1 oracle oinstall 102498304 May 20 11:31 1_41_813854676.dbf

-rw-r----- 1 oracle oinstall  71364608 May 20 15:48 1_42_813854676.dbf

[oracle@rhel5 archlog]$--刪除所有歸檔日誌,之後無法通過歸檔日誌恢復

[oracle@rhel5 archlog]$ rm -f *

[oracle@rhel5 ~]$ --使用BBED修改SCN

[oracle@rhel5 ~]$ bbed parfile=bbed.par password=blockedit

BBED: Release 2.0.0.0.0 - Limited Production on Mon May 20 15:56:48 2013

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

BBED> info

File#  Name                                                        Size(blks)

-----  ----                                                        ----------

     1  /u01/app/oraData/ORCL/System01.dbf                               41600

     2  /u01/app/oraData/ORCL/Undotbs01.dbf                              27136

     3  /u01/app/oraData/ORCL/Sysaux01.dbf                               41600

     6  /u01/lost_it.dbf                                                  1280

BBED> set dba 6,1

        DBA             0x01800001 (25165825 6,1)

BBED> map

File: /u01/lost_it.dbf (6)

Block: 1                                     Dba:0x01800001

------------------------------------------------------------

Data File Header

struct kcvfh, 676 bytes                    @0      

ub4 tailchk                                @8188   

--檢視檔案的kscnbas      

BBED> p kcvfhckp

struct kcvfhckp, 36 bytes                   @484    

   struct kcvcpscn, 8 bytes                 @484    

      ub4 kscnbas                           @484      0x000c91ac

      ub2 kscnwrp                           @488      0x0000

   ub4 kcvcptim                             @492      0x30a222b4

   ub2 kcvcpthr                             @496      0x0001

   union u, 12 bytes                        @500    

      struct kcvcprba, 12 bytes             @500    

         ub4 kcrbaseq                       @500      0x0000002a

         ub4 kcrbabno                       @504      0x00022078

         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

--修改SCNSYSTEM 表空間檔案的SCN一致

BBED> set offset 484

        OFFSET          484

BBED> d count 16

File: /u01/lost_it.dbf (6)

Block: 1                Offsets:  484 to  995           Dba:0x01800001

------------------------------------------------------------------------

ac910c00 00000000 b422a230 01000000

<32 bytes per line>

BBED> m /x b491

Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y

File: /u01/lost_it.dbf (6)

Block: 1                Offsets:  484 to  995           Dba:0x01800001

------------------------------------------------------------------------

b4910c00 00000000 b422a230 01000000

<32 bytes per line>

--檢視修改的結果,並未對RBA進行修改!

BBED> p kcvfhckp

struct kcvfhckp, 36 bytes                   @484    

   struct kcvcpscn, 8 bytes                 @484    

      ub4 kscnbas                           @484      0x000c91b4

      ub2 kscnwrp                           @488      0x0000

   ub4 kcvcptim                             @492      0x30a222b4

   ub2 kcvcpthr                             @496      0x0001

   union u, 12 bytes                        @500    

      struct kcvcprba, 12 bytes             @500   

         ub4 kcrbaseq                       @500      0x0000002a

         ub4 kcrbabno                       @504      0x00022078

         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> sum

Check value for File 6, Block 1:

current = 0x2c88, required = 0x2c90

--儲存修改結果

BBED> sum apply

Check value for File 6, Block 1:

current = 0x2c90, required = 0x2c90

BBED>

--回到SQLPLUS

SQL> alter database datafile 6 online;

alter database datafile 6 online

*

ERROR at line 1:

ORA-01113: file 6 needs media recovery if it was restored from backup, or END BACKUP if it was not

ORA-01110: data file 6: '/u01/lost_it.dbf'

SQL>--恢復6號檔案

SQL> recover datafile 6;

Media recovery complete.

SQL> alter database datafile 6 online;

Database altered.

--檢驗結

SQL> select table_name from dba_tables where tablespace_name='LOST_IT';

TABLE_NAME

------------------------------

LOST_DATA

T

SQL> select count(*) from t;

  COUNT(*)

----------

        10

SQL> select count(*) from lost_data;

  COUNT(*)

----------

      9895

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/429786/viewspace-776246/,如需轉載,請註明出處,否則將追究法律責任。

相關文章