BBED跳过归档恢复


实验:

(1)备份5号文件
SQL> select * from v$dbfile;

FILE# NAME
---------- -----------------------------------
4 /orcl_backup/cold/users01.dbf
3 /orcl_backup/cold/undotbs01.dbf
2 /orcl_backup/cold/sysaux01.dbf
1 /orcl_backup/cold/system01.dbf
5 /orcl_backup/cold/tp01.dbf

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

FILE# CHECKPOINT_CHANGE# NAME
---------- ------------------ -----------------------------------
1 5170101 /orcl_backup/cold/system01.dbf
2 5170101 /orcl_backup/cold/sysaux01.dbf
3 5170101 /orcl_backup/cold/undotbs01.dbf
4 5170101 /orcl_backup/cold/users01.dbf
5 5170101 /orcl_backup/cold/tp01.dbf

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

FILE# CHECKPOINT_CHANGE# NAME
---------- ------------------ -----------------------------------
1 5170101 /orcl_backup/cold/system01.dbf
2 5170101 /orcl_backup/cold/sysaux01.dbf
3 5170101 /orcl_backup/cold/undotbs01.dbf
4 5170101 /orcl_backup/cold/users01.dbf
5 5170101 /orcl_backup/cold/tp01.dbf


(2)RMAN> backup datafile 5;

Starting backup at 05-JAN-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=14 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/orcl_backup/cold/tp01.dbf
channel ORA_DISK_1: starting piece 1 at 05-JAN-15
channel ORA_DISK_1: finished piece 1 at 05-JAN-15
piece handle=/app/oracle/fast_recovery_area/ORCL/backupset/2015_01_05/o1_mf_nnndf_TAG20150105T174653_bbphng6v_.bkp tag=TAG20150105T174653 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-JAN-15

(3)查看检查点有没变

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

FILE# CHECKPOINT_CHANGE# NAME
---------- ------------------ -----------------------------------
1 5170101 /orcl_backup/cold/system01.dbf
2 5170101 /orcl_backup/cold/sysaux01.dbf
3 5170101 /orcl_backup/cold/undotbs01.dbf
4 5170101 /orcl_backup/cold/users01.dbf
5 5170158 /orcl_backup/cold/tp01.dbf

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

FILE# CHECKPOINT_CHANGE# NAME
---------- ------------------ -----------------------------------
1 5170101 /orcl_backup/cold/system01.dbf
2 5170101 /orcl_backup/cold/sysaux01.dbf
3 5170101 /orcl_backup/cold/undotbs01.dbf
4 5170101 /orcl_backup/cold/users01.dbf
5 5170158 /orcl_backup/cold/tp01.dbf

(4)切换日志,产生归档
SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.


SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /app/oracle/archive_log
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1

(5)查看目前所在的日志
SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC
---------- ---------- ---------- ---------- ---------- ---------- ---
STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------------- ------------- --------- ------------ ---------
1 1 13 52428800 512 1 NO
CURRENT 5170199 05-JAN-15 2.8147E+14

2 1 11 52428800 512 1 YES
INACTIVE 5170193 05-JAN-15 5170196 05-JAN-15

3 1 12 52428800 512 1 YES
INACTIVE 5170196 05-JAN-15 5170199 05-JAN-15


(6)QL> create table t1(id number, name varchar2(100));

Table created.

SQL> insert into t1 values(5,'BBBBB');

1 row created.

SQL> COMMIT;

Commit complete.

SQL> alter system switch logfile;

System altered. ------写到13号归档。

SQL> SELECT * FROM V$LOG;

GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC
---------- ---------- ---------- ---------- ---------- ---------- ---
STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------------- ------------- --------- ------------ ---------
1 1 13 52428800 512 1 YES
ACTIVE 5170199 05-JAN-15 5170326 05-JAN-15

2 1 14 52428800 512 1 NO
CURRENT 5170326 05-JAN-15 2.8147E+14

3 1 12 52428800 512 1 YES
INACTIVE 5170196 05-JAN-15 5170199 05-JAN-15

 


(7)表空间offline

 SQL> alter tablespace tp1 offline;

Tablespace altered


(8)删除datafile 5 和归档日志
[oracle@evancao ~]$ rm -rf /orcl_backup/cold/tp01.dbf
[oracle@evancao archive_log]$ rm -rf *


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

FILE# CHECKPOINT_CHANGE# NAME
---------- ------------------ -----------------------------------
1 5170199 /orcl_backup/cold/system01.dbf
2 5170199 /orcl_backup/cold/sysaux01.dbf
3 5170199 /orcl_backup/cold/undotbs01.dbf
4 5170199 /orcl_backup/cold/users01.dbf
5 0

 

(9)在RMAN下restore

RMAN> restore datafile 5;

Starting restore at 05-JAN-15
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00005 to /orcl_backup/cold/tp01.dbf
channel ORA_DISK_1: reading from backup piece /app/oracle/fast_recovery_area/ORCL/backupset/2015_01_05/o1_mf_nnndf_TAG20150105T174653_bbphng6v_.bkp
channel ORA_DISK_1: piece handle=/app/oracle/fast_recovery_area/ORCL/backupset/2015_01_05/o1_mf_nnndf_TAG20150105T174653_bbphng6v_.bkp tag=TAG20150105T174653
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 05-JAN-15

 

SQL> select file#,status ,name from v$datafile
2 ;

FILE# STATUS NAME
---------- ------- -----------------------------------
1 SYSTEM /orcl_backup/cold/system01.dbf
2 ONLINE /orcl_backup/cold/sysaux01.dbf
3 ONLINE /orcl_backup/cold/undotbs01.dbf
4 ONLINE /orcl_backup/cold/users01.dbf
5 OFFLINE /orcl_backup/cold/tp01.dbf

SQL> alter tablespace tp1 online;
alter tablespace tp1 online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '/orcl_backup/cold/tp01.dbf'
报错需要恢复


SQL> recover datafile 5;
ORA-00279: change 5170158 generated at 01/05/2015 17:46:54 needed for thread 1
ORA-00289: suggestion : /app/oracle/archive_log/1_9_868145345.dbf
ORA-00280: change 5170158 for thread 1 is in sequence #9


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}



ORA-00308: cannot open archived log '/app/oracle/archive_log/1_9_868145345.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


(10)SQL> shutdown immediate


(11)使用bbed

BBED> set file 5
FILE# 5

BBED> set block 1
BLOCK# 1

BBED> show
FILE# 5
BLOCK# 1
OFFSET 0
DBA 0x01400001 (20971521 5,1)
FILENAME /orcl_backup/cold/tp01.dbf
BIFILE bifile.bbd
LISTFILE /tmp/filelist.txt
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No

BBED> map /v
File: /orcl_backup/cold/tp01.dbf (5)
Block: 1 Dba:0x01400001
------------------------------------------------------------
Data File Header

struct kcvfh, 860 bytes @0
struct kcvfhbfh, 20 bytes @0
struct kcvfhhdr, 76 bytes @20
ub4 kcvfhrdb @96
struct kcvfhcrs, 8 bytes @100
ub4 kcvfhcrt @108
ub4 kcvfhrlc @112
struct kcvfhrls, 8 bytes @116
ub4 kcvfhbti @124
struct kcvfhbsc, 8 bytes @128
ub2 kcvfhbth @136
ub2 kcvfhsta @138
struct kcvfhckp, 36 bytes @484
ub4 kcvfhcpc @140
ub4 kcvfhrts @144
ub4 kcvfhccc @148
struct kcvfhbcp, 36 bytes @152
ub4 kcvfhbhz @312
struct kcvfhxcd, 16 bytes @316
sword kcvfhtsn @332
ub2 kcvfhtln @336
text kcvfhtnm[30] @338
ub4 kcvfhrfn @368
struct kcvfhrfs, 8 bytes @372
ub4 kcvfhrft @380
struct kcvfhafs, 8 bytes @384
ub4 kcvfhbbc @392
ub4 kcvfhncb @396
ub4 kcvfhmcb @400
ub4 kcvfhlcb @404
ub4 kcvfhbcs @408
ub2 kcvfhofb @412
ub2 kcvfhnfb @414
ub4 kcvfhprc @416
struct kcvfhprs, 8 bytes @420
struct kcvfhprfs, 8 bytes @428
ub4 kcvfhtrt @444

ub4 tailchk @8188


偏移量:

484 scn
500 rba


@484
(12)BBED> p kcvfhckp
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x004ee3ee
ub2 kscnwrp @488 0x0000
ub4 kcvcptim @492 0x33bfda0e
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x00000009 ===9
ub4 kcrbabno @504 0x00000016 ===22块
ub2 kcrbabof @508 0x0010 ===16字节
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

SQL> SELECT TO_number ('004ee3ee','xxxxxxxxxxxxx') from dual;

TO_NUMBER('004EE3EE','XXXXXXXXXXXXX')
-------------------------------------
5170158 -----记在文件头484偏移量的位置。
0x00 4e ea 9dea4e00


9号归档已经删除。

 

BBED> modify /x d offset 500
File: /orcl_backup/cold/tp01.dbf (5)
Block: 1 Offsets: 500 to 1011 Dba:0x01400001
------------------------------------------------------------------------
0d000000 16000000 1000b026 02000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 0d000d00 0d000100 00000000 00000000
00000000 02004001 de300f00 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

<32 bytes per line>

只改rba 会报 600的错误
SQL> recover datafile 5;
ORA-00283: recovery session canceled due to errors
ORA-00600: internal error code, arguments: [2608], [1], [0], [5170158], [0],
[5170199], [], [], [], [], [], []


(13)修改SCN

BBED> modify /x 9dea offset 484
File: /orcl_backup/cold/tp01.dbf (5)
Block: 1 Offsets: 484 to 499 Dba:0x01400001
------------------------------------------------------------------------
9dea4e00 00000000 0edabf33 01000000

<32 bytes per line>

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


SQL> recover datafile 5;
Media recovery complete.

SQL> alter database open;

Database altered.

SQL> alter tablespace tp1 online;

Tablespace altered.

查询没有表,说明如果从2号块上开始就能还原到建表前的状态。可以再试一把。

posted @ 2015-01-06 10:47  修行从29开始  阅读(270)  评论(0编辑  收藏  举报