BBED跳过归档
1 通过BBED 跳过归档,以当前数据库 8号文件为例: 2 SQL> select * from v$dbfile where file#=8; 3 FILE# NAME 4 ---------- -------------------------------------------------- 5 8 /u01/app/oracle/oradata/orcl/d4k01.dbf 6 7 8 1、rman 备份 8号文件 9 RMAN> backup datafile '/u01/app/oracle/oradata/orcl/d4k01.dbf' format '/home/oracle/back/d4k01_%U.bak'; 10 Starting backup at 03-SEP-16 11 using channel ORA_DISK_1 12 channel ORA_DISK_1: starting full datafile backup set 13 channel ORA_DISK_1: specifying datafile(s) in backup set 14 input datafile file number=00008 name=/u01/app/oracle/oradata/orcl/d4k01.dbf 15 channel ORA_DISK_1: starting piece 1 at 03-SEP-16 16 channel ORA_DISK_1: finished piece 1 at 03-SEP-16 17 piece handle=/home/oracle/back/d4k01_03reraaj_1_1.bak tag=TAG20160903T004403 comment=NONE 18 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 19 Finished backup at 03-SEP-16 20 21 22 2、进行多次日志切换(用于产生多个日志归档) 23 SQL> alter system switch logfile; 24 25 26 3、将 8 号数据文件脱机,并删除 27 SQL> alter database datafile '/u01/app/oracle/oradata/orcl/d4k01.dbf' offline; 28 rm -rf /u01/app/oracle/oradata/orcl/d4k01.dbf 29 30 4、rman还原 8 号文件 31 RMAN> restore datafile '/u01/app/oracle/oradata/orcl/d4k01.dbf'; 32 Starting restore at 03-SEP-16 33 using channel ORA_DISK_1 34 channel ORA_DISK_1: starting datafile backup set restore 35 channel ORA_DISK_1: specifying datafile(s) to restore from backup set 36 channel ORA_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/orcl/d4k01.dbf 37 channel ORA_DISK_1: reading from backup piece /home/oracle/back/d4k01_03reraaj_1_1.bak 38 channel ORA_DISK_1: piece handle=/home/oracle/back/d4k01_03reraaj_1_1.bak tag=TAG20160903T004403 39 channel ORA_DISK_1: restored backup piece 1 40 channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 41 Finished restore at 03-SEP-16 42 43 44 5、联机 8号数据文件,提示需要介质恢复 45 因为在rman备份的数据文件,写入数据文件头的检查点(V$DATAFILE_HEADER 视图的 CHECKPOINT_CHANGE#) 是备份时候的检查点编号, 46 切换多次日志后,在控制文件(V$DATAFILE 视图的 CHECKPOINT_CHANGE#) 里的是当前数据库检查点编号,这两个编号不一致, 47 所以需要介质恢复,也就是读取备份之后,所产生的redo日志。 48 49 6、介质恢复的起点,记录在数据文件头,分两部分(检查点和rba) 50 51 7、dump数据文件头 52 SQL> alter system set events 'immediate trace name file_hdrs level 10'; 53 54 8、在dump文件中找到 8 号数据文件对应的内容 55 DATA FILE #8: 56 name #28: /u01/app/oracle/oradata/orcl/d4k01.dbf 57 creation size=12800 block size=8192 status=0x1c head=28 tail=28 dup=1 58 tablespace 11, index=9 krfil=8 prev_file=0 59 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00 60 Checkpoint cnt:92 scn: 0x0000.004218e6 09/03/2016 00:45:06 61 Stop scn: 0x0000.00421998 09/03/2016 00:52:57 62 Creation Checkpointed at scn: 0x0000.00325a8a 06/15/2016 18:20:45 63 thread:1 rba:(0x30.992c.10) 64 -------------------------------------------------------------------------- 65 Tablespace #11 - D4K rel_fn:8 66 Creation at scn: 0x0000.00325a8a 06/15/2016 18:20:45 67 Backup taken at scn: 0x0000.00000000 01/01/1988 00:00:00 thread:0 68 reset logs count:0x3661a1e6 scn: 0x0000.002387eb 69 prev reset logs count:0x361abe00 scn: 0x0000.000e6c20 70 recovered at 09/03/2016 01:00:43 71 status:0x0 root dba:0x00000000 chkpt cnt: 77 ctl cnt:76 72 begin-hot-backup file size: 0 73 Checkpointed at scn: 0x0000.00421867 09/03/2016 00:44:03 74 thread:1 rba:(0x69.1056d.10) 75 76 在dump文件里面8号文件有两大部分: 77 1、data file 8# (这部分来着控制文件,是当前日志的检查点), 78 2、Tablespace #11 - D4K rel_fn:8 (这是8号文件对应的表空间,这部分数据来自数据文件头,是需要修改的部分) 79 80 9、修改 rba和 checkpoint at scn ,将其修改到指定的归档日志开始恢复(归档日志的序列号和检查点) 81 通过计算如下rba 的到 从 105 号归档的 66925号块开始恢复 (16进制69为10进制105...) 82 Checkpointed at scn: 0x0000.00421867 09/03/2016 00:44:03 83 thread:1 rba:(0x69.1056d.10) 84 85 查询归档日志视图(V$archived_log),获取序列号和检查点信息 86 SQL> select sequence#,first_change# from v$archived_log; 87 SEQUENCE# FIRST_CHANGE# 88 ---------- ------------- 89 103 4299914 90 104 4300188 91 105 4324652 92 ................. 93 120 4331692 94 121 4331695 95 122 4331698 96 123 4331701 97 124 4331704 98 125 4331707 99 126 4331710 100 127 4331713 101 128 4331716 102 129 4331719 103 104 105 10、通过BBED,修改rba和检查点,将其改到第120号归档 106 BBED> show all; 107 FILE# 8 108 BLOCK# 1 109 OFFSET 0 110 DBA 0x02000001 (33554433 8,1) 111 FILENAME /u01/app/oracle/oradata/orcl/d4k01.dbf 112 BIFILE bifile.bbd 113 LISTFILE /home/oracle/bbed.lit 114 BLOCKSIZE 8192 115 MODE Edit 116 EDIT Unrecoverable 117 IBASE Dec 118 OBASE Dec 119 WIDTH 80 120 COUNT 512 121 LOGFILE log.bbd 122 SPOOL No 123 124 BBED> dump 125 File: /u01/app/oracle/oradata/orcl/d4k01.dbf (8) 126 Block: 1 Offsets: 0 to 511 Dba:0x02000001 127 ------------------------------------------------------------------------ 128 0ba20000 01000002 00000000 00000104 86390000 00000000 0000200b 7e099055 129 4f52434c 00000000 b39a0000 00960000 00200000 08000300 00000000 00000000 130 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 131 00000000 8a5a3200 00000000 7dd78336 e6a16136 eb872300 00000000 00000000 132 00000000 00000000 00000000 4d000000 3baded36 4c000000 00000000 00000000 133 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 134 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 135 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 136 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 137 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 138 00000000 00000000 00000000 0b000000 03004434 4b000000 00000000 00000000 139 00000000 00000000 00000000 00000000 08000000 00000000 00000000 00000000 140 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 141 00be1a36 206c0e00 00000000 00000000 00000000 00000000 00000000 00000000 142 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 143 00000000 67184200 00006f6c 53a9ed36 01000000 69000000 6d050100 1000ffff 144 <32 bytes per line> 145 146 147 在bbed的dump中查找 rba的日志块号(1056d)和检查点(421867),在bbed中是反的,即为:6d0501 和 671842 148 使用find命令: 149 BBED> find /x 6d0501 150 File: /u01/app/oracle/oradata/orcl/d4k01.dbf (8) 151 Block: 1 Offsets: 504 to 1015 Dba:0x02000001 152 BBED> find /x 67184200 153 File: /u01/app/oracle/oradata/orcl/d4k01.dbf (8) 154 Block: 1 Offsets: 484 to 995 Dba:0x02000001 155 156 将检查点修改为120号归档的检查点(4331692),转换为16进制为(4218AC),反过来为(AC1842) 157 BBED> modify /x AC1842 offset 484 158 159 160 将rba的日志序列号改为(120),转换16进制为(78) 161 BBED> modify /x 78 offset 500 162 163 164 将rba中的日志块号改小一点,改为从第三号块开始 165 BBED> modify /x 110000 offset 504 166 167 168 改完dump结果如下: 169 BBED> dump 170 File: /u01/app/oracle/oradata/orcl/d4k01.dbf (8) 171 Block: 1 Offsets: 0 to 511 Dba:0x02000001 172 ------------------------------------------------------------------------ 173 0ba20000 01000002 00000000 00000104 213c0000 00000000 0000200b 7e099055 174 4f52434c 00000000 b39a0000 00960000 00200000 08000300 00000000 00000000 175 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 176 00000000 8a5a3200 00000000 7dd78336 e6a16136 eb872300 00000000 00000000 177 00000000 00000000 00000000 4d000000 3baded36 4c000000 00000000 00000000 178 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 179 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 180 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 181 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 182 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 183 00000000 00000000 00000000 0b000000 03004434 4b000000 00000000 00000000 184 00000000 00000000 00000000 00000000 08000000 00000000 00000000 00000000 185 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 186 00be1a36 206c0e00 00000000 00000000 00000000 00000000 00000000 00000000 187 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 188 00000000 ac184200 00006f6c 53a9ed36 01000000 78000000 11000000 1000ffff 189 <32 bytes per line> 190 191 重新计算校验和 192 BBED> sum apply 193 Check value for File 8, Block 1: 194 current = 0x3c21, required = 0x3c21 195 196 197 11、恢复8号文件 198 SQL> recover datafile '/u01/app/oracle/oradata/orcl/d4k01.dbf'; 199 ORA-00279: change 4331692 generated at 09/03/2016 00:44:03 needed for thread 1 200 ORA-00289: suggestion : /u01/app/oracle/oradata/archive/1_120_912368102.dbf 201 ORA-00280: change 4331692 for thread 1 is in sequence #120 202 Specify log: {<RET>=suggested | filename | AUTO | CANCEL} 203 AUTO 204 ORA-00279: change 4331695 generated at 09/03/2016 00:45:02 needed for thread 1 205 ORA-00289: suggestion : /u01/app/oracle/oradata/archive/1_121_912368102.dbf 206 ORA-00280: change 4331695 for thread 1 is in sequence #121