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 和归档日志
[[email protected] ~]$ rm -rf /orcl_backup/cold/tp01.dbf
[[email protected] 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号块上开始就能还原到建表前的状态。可以再试一把。

时间: 2024-10-16 11:04:36

BBED跳过归档恢复的相关文章

使用BBED跳过归档进行恢复

https://blog.csdn.net/gumengkai/article/details/53311390 使用BBED跳过归档进行恢复 数据库启动异常,提示6号文件丢失 SQL> startup ORACLE instance started. Total System Global Area 776646656 bytes Fixed Size 2257272 bytes Variable Size 490737288 bytes Database Buffers 281018368

【Oracle】使用BBED跳过丢失的归档

在recover datafile的过程当中如果丢失了需要的归档将使得recover无法进行,使用bbed工具可以跳过丢失的归档进行recover datafile. 实验过程如下: [email protected]>select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Rele

Oracle11gr2_ADG管理之跳归档恢复dg实战

模拟故障 关闭备库 SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. 模拟插入数据,归档,并且删除归档 SQL> insert into test values(23); 1 row created. SQL> alter system switch logfile; System altered. SQL> insert into test value

用热备+归档恢复损坏的非系统表空间

通常,我们都是用RMAN去还原数据文件,再利用归档做恢复,如果没有有效的备份集,但是有热备份生成的文件,那么一样可以进行恢复,这里演示的是非系统表空间对应的数据文件损坏后的恢复. --首先获取热备份的语句 SQL> select 'alter tablespace '||tablespace_name|| ' begin backup;' 2  ||chr(10) 3  ||'cp '||file_name||' /u01/' 4  ||chr(10) 5  ||'alter tablespac

&lt;a&gt;标签的取消跳转和恢复

一.取消<a>的跳转,可以绑定click事件,在click里return false;(此时就算a有一个href跳转地址也没用了) $("#previewbtn").click(function(){return false}); 二.恢复<a>的跳转,可以取消绑定的click,这时<a>就可以跳转到指定链接了. $("#previewbtn").unbind('click');

Linux命令 文件备份归档恢复

cp [功能说明] 文件的备份 英文xxxx  #cp命令将源文件复制到另外安全的地方,复制的文件和源文件是两个相互独立的文件,对认识一个文件的操作不影响另一个文件,但与符号链接文件中的硬链接是有区别的 [语法格式] cp[参数][源文件或目录][目标目录] 或cp[选项][源文件][目标文件] [选项参数] 参数 说明 -a 该参数通常在复制目录时使用.保留链接,文件属性,并递归的复制目录,其作用等于-d,-p和-r参数的组合 -b 在复制文件的时候,若目标文件存在,在删除,覆盖目标文件前应做

oracle dis系列课程总结

1 bbed安装和介绍 --1 bbed的安装--(Oracle Block Brower and EDitor Tool) 2 controlfile 丢失的恢复 --1 控制文件没有备份全部丢失 --1.哪些场景下需要用alter database open resetlogs打开库? --2.在删除所有controlfile和redolog日志的情况下shutdown abort异常关库,能用resetlogs打开库吗?为什么? --3.用dd命令损坏其中一个控制文件的文件头(1号块),然

RMAN数据库恢复之恢复归档日志文件

恢复归档日志文件如果只是为了在恢复数据文件之后应用归档文件,那并不需要手动对归档文件进行恢复,RMAN会在RECOVER时自动对适当的归档进行恢复.单独恢复归档文件一般是有特别的需求,如创建了Data Guard环境.Standby端丢失了部分归档文件,需要从Primary端重新获取.1.恢复全部归档日志文件RMAN> RESTORE ARCHIVELOG ALL; 2.恢复归档序号为20至30之间的归档文件RMAN> RESTOER ARCHIVELOG SEQUENCE BETWEEN 2

使用bbed恢复表数据

对于表级别的数据恢复,ORACLE提供了多种恢复方法:flashback query,logmnr等. 本文通过演示样例演示使用bbed的copy命令恢复用户误删除或者损坏的表数据,当然我们也能够使用该方法来恢复其它数据. 实验过程: SQL> select tablespace_name,file_name from dba_data_files; TABLESPACE_NAME FILE_NAME --------------- -------------------------------