A-A+
浅析redo
该文档从insert,update,delete所产生的dump文件进行分析并做简要说明
数据库版本
sys@ora11gr2> select * from gv$version; INST_ID BANNER ---------- -------------------------------------------------------------------------------- 1 Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 1 PL/SQL Release 11.2.0.3.0 - Production 1 CORE 11.2.0.3.0 Production 1 TNS for Linux: Version 11.2.0.3.0 - Production 1 NLSRTL Version 11.2.0.3.0 - Production 5 rows selected. sys@ora11gr2> @registry_history.sql ACTION_TIME ACTION NAMESPACE VERSION ID COMMENTS BUNDLE_SER -------------------- -------------------- -------------------- ---------- ---------- ------------------------------ ---------- 25-DEC-2012 13:24:04 APPLY SERVER 11.2.0.3 4 PSU 11.2.0.3.4 PSU 1 row selected.
(一)分析insert产生的redo
创建测试数据
sys@ora11gr2> create table yallonking(id number,name varchar2(20)); Table created. sys@ora11gr2> alter system checkpoint; System altered. sys@ora11gr2> @show_current_scn CURRENT_SCN ----------- 1144520 1 row selected. sys@ora11gr2> insert into yallonking values(1,'yallonking'); 1 row created. sys@ora11gr2> commit; Commit complete. sys@ora11gr2> alter system checkpoint; System altered. sys@ora11gr2> @show_current_scn CURRENT_SCN ----------- 1144530 1 row selected. sys@ora11gr2> @show_current_logfile; MEMBER ---------------------------------------------------------------------------------------------------- /u01/app/oracle/oradata/ora11gr2/redo01.log 1 row selected. sys@ora11gr2> @dump_logfile_by_min_max_scn /u01/app/oracle/oradata/ora11gr2/redo01.log 1144520 1144530 old 1: alter system dump logfile '&&1' scn min '&&2' scn max '&&3' new 1: alter system dump logfile '/u01/app/oracle/oradata/ora11gr2/redo01.log' scn min '1144520' scn max '1144530' System altered. TRACE_FILE_NAME ---------------------------------------------------------------------------------------------------- /u01/app/oracle/diag/rdbms/ora11gr2/ora11gr2/trace/ora11gr2_ora_21655.trc 1 row selected.
--相关说明:
--Thread - redo log thread number --RBA - redo byte address - address of redo record within redo log. Format is <sequence_number>.<block_number>.<offset> --LEN - length of redo record in bytes including header --VLD - see below --SCN - system change number of redo record --SUBSCN: Unknown --Timestamp e.g. 05/07/2009 21:53:48 --VLD列的说明: --Mnemonic Value Description --KCRVOID 0 The contents are not valid --KCRVALID 1 Includes change vectors --KCRDEPND 2 Includes commit SCN --KCRVOID 4 Includes dependent SCN --KCRNMARK 8 New SCN mark record. SCN allocated exactly at this point in the redo log by this instance --KCROMARK 16 Old SCN mark record. SCN allocated at or before this point in the redo. May be allocated by another instance --KCRORDER 32 New SCN was allocated to ensure redo for some block would be ordered by inc/seq# when redo sorted by SCN --操作码说明 --Level Description --4 Block Cleanout --5 Transaction Layer (Undo) --10 Index Operation --11 Table Operation (DML) --13 Block Allocation --14 Extent Allocation --17 Backup Management --18 Online Backup --19 Direct Load --20 Transaction Metadata (LogMiner) --22 Space Management (ASSM) --23 Block Write (DBWR) --24 DDL Statement
查看dump文件
[oracle@rhl6 dba_scripts]$ cat /u01/app/oracle/diag/rdbms/ora11gr2/ora11gr2/trace/ora11gr2_ora_21655.trc Trace file /u01/app/oracle/diag/rdbms/ora11gr2/ora11gr2/trace/ora11gr2_ora_21655.trc Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1 System name: Linux Node name: rhl6.0x64 Release: 2.6.32-71.el6.x86_64 Version: #1 SMP Wed Sep 1 01:33:01 EDT 2010 Machine: x86_64 VM name: VMWare Version: 6 Instance name: ora11gr2 Redo thread mounted by this instance: 1 Oracle process number: 26 Unix process pid: 21655, image: oracle@rhl6.0x64 (TNS V1-V3) *** 2013-12-21 18:09:13.933 *** SESSION ID:(35.39) 2013-12-21 18:09:13.933 *** CLIENT ID:() 2013-12-21 18:09:13.933 *** SERVICE NAME:(SYS$USERS) 2013-12-21 18:09:13.933 *** MODULE NAME:(sqlplus@rhl6.0x64 (TNS V1-V3)) 2013-12-21 18:09:13.933 *** ACTION NAME:() 2013-12-21 18:09:13.933 Initial buffer sizes: read 1024K, overflow 832K, change 805K Log read is SYNCHRONOUS though disk_asynch_io is enabled! DUMP OF REDO FROM FILE '/u01/app/oracle/oradata/ora11gr2/redo01.log' Opcodes *.* RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff SCNs: scn: 0x0000.001176c8 (1144520) thru scn: 0x0000.001176d2 (1144530) -->dump的scn范围 Times: creation thru eternity FILE HEADER: Compatibility Vsn = 186646528=0xb200000 Db ID=119524391=0x71fcc27, Db Name='ORA11GR2' -->dbid和db_name Activation ID=119541799=0x7201027 Control Seq=2793=0xae9, File size=102400=0x19000 File Number=1, Blksiz=512, File Type=2 LOG -->log文件的大小 descrip:"Thread 0001, Seq# 0000000187, SCN 0x0000001151ab-0xffffffffffff" thread: 1 nab: 0xffffffff seq: 0x000000bb hws: 0x5 eot: 1 dis: 0 resetlogs count: 0x2fdc16a7 scn: 0x0000.00000001 (1) prev resetlogs count: 0x0 scn: 0x0000.00000000 Low scn: 0x0000.001151ab (1135019) 12/21/2013 04:22:12 --记录前一个scn的时间点 Next scn: 0xffff.ffffffff 01/01/1988 00:00:00 Enabled scn: 0x0000.00000001 (1) 12/25/2012 10:28:49 Thread closed scn: 0x0000.00115f5d (1138525) 12/21/2013 06:00:13 Disk cksum: 0x551b Calc cksum: 0x551b Terminal recovery stop scn: 0x0000.00000000 Terminal recovery 01/01/1988 00:00:00 Most recent redo scn: 0x0000.00000000 Largest LWN: 0 blocks End-of-redo stream : No Unprotected mode Miscellaneous flags: 0x800000 Thread internal enable indicator: thr: 0, seq: 0 scn: 0x0000.00000000 Zero blocks: 0 Format ID is 2 redo log key is 21456ab701e44ef1153cb3aa1444478 redo log key flag is 5 Enabled redo threads: 1 REDO RECORD - Thread:1 RBA: 0x0000bb.00003cc1.002c LEN: 0x00b8 VLD: 0x01 -->开始记录insert操作的redo SCN: 0x0000.001176c8 SUBSCN: 1 12/21/2013 18:08:17 -->scn:001176c8(1144520) (LWN RBA: 0x0000bb.00003cc0.0010 LEN: 0002 NST: 0001 SCN: 0x0000.001176c5) CHANGE #1 TYP:0 CLS:27 AFN:3 DBA:0x00c000d0 OBJ:4294967295 SCN:0x0000.001176c3 SEQ:1 OP:5.4 ENC:0 RBL:0 ktucm redo: slt: 0x0001 sqn: 0x000003a7 srt: 0 sta: 9 flg: 0x2 ktucf redo: uba: 0x00c00281.00d1.3b ext: 5 spc: 676 fbi: 1 --OP:5.4指的是更新事务表,可以理解为事务开始,通过uba可以找到事务相关信息 --上边OBJ:4294967295=2的32次方-1,是一个特殊的值,AFN:3指的是3号文件也就是undo文件 CHANGE #2 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:17.28 ENC:0 STANDBY METADATA CACHE INVALIDATION KQR INFO: [f61c5d2b, 2, 0] [7d7929f7, 8, 6153] KGL INFO: [6af25f1f.e8a5bd88.6f5cabdc.efc9104d, 1] [6af25f1f.e8a5bd88.6f5cabdc.efc9104d, 1] --OP:17.28:level-17是和备份相关的,28不详,猜测是和备库恢复相关 REDO RECORD - Thread:1 RBA: 0x0000bb.00003cc2.0010 LEN: 0x0220 VLD: 0x06 SCN: 0x0000.001176cb SUBSCN: 1 12/21/2013 18:08:25 (LWN RBA: 0x0000bb.00003cc2.0010 LEN: 0002 NST: 0001 SCN: 0x0000.001176ca) CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 3 rdba: 0x00c00281 BFT:(1024,12583553) non-BFT:(3,641) scn: 0x0000.001176c7 seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c00282 BFT:(1024,12583554) non-BFT:(3,642) scn: 0x0000.001176c2 seq: 0x05 flg:0x04 Block Written - afn: 3 rdba: 0x00c00163 BFT:(1024,12583267) non-BFT:(3,355) scn: 0x0000.001176b2 seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c00100 BFT:(1024,12583168) non-BFT:(3,256) scn: 0x0000.001176b3 seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c000e6 BFT:(1024,12583142) non-BFT:(3,230) scn: 0x0000.001176b7 seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c000e0 BFT:(1024,12583136) non-BFT:(3,224) scn: 0x0000.001176b8 seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c000d0 BFT:(1024,12583120) non-BFT:(3,208) scn: 0x0000.001176c8 seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c000b0 BFT:(1024,12583088) non-BFT:(3,176) scn: 0x0000.001176af seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c000b1 BFT:(1024,12583089) non-BFT:(3,177) scn: 0x0000.001176ae seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c000ac BFT:(1024,12583084) non-BFT:(3,172) scn: 0x0000.001176a4 seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c000a0 BFT:(1024,12583072) non-BFT:(3,160) scn: 0x0000.001176a5 seq: 0x01 flg:0x04 Block Written - afn: 1 rdba: 0x004138a8 BFT:(1024,4274344) non-BFT:(1,80040) scn: 0x0000.001176be seq: 0x02 flg:0x04 Block Written - afn: 1 rdba: 0x004122b0 BFT:(1024,4268720) non-BFT:(1,74416) scn: 0x0000.001176c3 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x0041114f BFT:(1024,4264271) non-BFT:(1,69967) scn: 0x0000.001176c0 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x00411149 BFT:(1024,4264265) non-BFT:(1,69961) scn: 0x0000.001176c8 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x0041114a BFT:(1024,4264266) non-BFT:(1,69962) scn: 0x0000.001176c8 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x004108ec BFT:(1024,4262124) non-BFT:(1,67820) scn: 0x0000.001176c8 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x00410722 BFT:(1024,4261666) non-BFT:(1,67362) scn: 0x0000.001176c8 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x0040fd66 BFT:(1024,4259174) non-BFT:(1,64870) scn: 0x0000.001176c8 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x0040f5b5 BFT:(1024,4257205) non-BFT:(1,62901) scn: 0x0000.001176c8 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x0040c3c8 BFT:(1024,4244424) non-BFT:(1,50120) scn: 0x0000.001176c8 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x00407643 BFT:(1024,4224579) non-BFT:(1,30275) scn: 0x0000.001176c8 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x004059e0 BFT:(1024,4217312) non-BFT:(1,23008) scn: 0x0000.001176c8 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x00403437 BFT:(1024,4207671) non-BFT:(1,13367) scn: 0x0000.001176c8 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x0040342f BFT:(1024,4207663) non-BFT:(1,13359) scn: 0x0000.001176c8 seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x00400090 BFT:(1024,4194448) non-BFT:(1,144) scn: 0x0000.001176c2 seq: 0x01 flg:0x04 Block Written - afn: 1 rdba: 0x00400002 BFT:(1024,4194306) non-BFT:(1,2) scn: 0x0000.001176be seq: 0x02 flg:0x04 Block Written - afn: 1 rdba: 0x00400003 BFT:(1024,4194307) non-BFT:(1,3) scn: 0x0000.001176be seq: 0x01 flg:0x04 --OP:23.1指的是dummy block written callback REDO RECORD - Thread:1 RBA: 0x0000bb.00003cc4.0010 LEN: 0x02b0 VLD: 0x0d SCN: 0x0000.001176d2 SUBSCN: 1 12/21/2013 18:08:41 (LWN RBA: 0x0000bb.00003cc4.0010 LEN: 0002 NST: 0001 SCN: 0x0000.001176d1) CHANGE #1 TYP:1 CLS:1 AFN:1 DBA:0x004138a9 OBJ:71689 SCN:0x0000.001176cf SEQ:1 OP:13.5 ENC:0 RBL:0 KTSFRBFMT (block format) redo: Segobjd: 0x00011809 type: 1 itls: 2 cscn: 0x0000.001176cf --OP:13.5指的是new block格式化一个新的segment head CHANGE #2 TYP:0 CLS:1 AFN:1 DBA:0x004138a9 OBJ:71689 SCN:0x0000.001176d2 SEQ:1 OP:13.6 ENC:0 RBL:0 KTSFRBLNK (block link modify) redo: Opcode: LSET (lock set) Next dba: 0x004138aa itli: 0 CHANGE #3 TYP:0 CLS:1 AFN:1 DBA:0x004138a9 OBJ:71689 SCN:0x0000.001176d2 SEQ:2 OP:13.6 ENC:0 RBL:0 KTSFRBLNK (block link modify) redo: Opcode: LWRT (lock write) Next dba: 0x00000000 itli: 0 --OP:13.6指的是format block格式化一个数据块 CHANGE #4 TYP:0 CLS:4 AFN:1 DBA:0x004138a8 OBJ:71689 SCN:0x0000.001176be SEQ:2 OP:13.7 ENC:0 RBL:0 KTSFRGRP (fgb/shdr modify freelist) redo: Opcode: HWMMV (move hwm) NBK: 1 Opcode: LUPD_LLIST (link a list) Slot no: 0, Count: 1 Flag: = 1 xid or slot0 ccnt: 0x0000.000.00000001 Head: 0x004138a9 Tail: 0x004138a9 --OP:13.7指的是修改空闲列表,可以理解为设置高水位线 CHANGE #5 TYP:0 CLS:1 AFN:1 DBA:0x004138a9 OBJ:71689 SCN:0x0000.001176d2 SEQ:3 OP:11.2 ENC:0 RBL:0 KTB Redo op: 0x01 ver: 0x01 compat bit: 4 (post-11) padding: 1 op: F xid: 0x0008.002.00000303 uba: 0x00c0039c.00ea.1a KDO Op code: IRP row dependencies Disabled xtype: XA flags: 0x00000000 bdba: 0x004138a9 hdba: 0x004138a8 itli: 1 ispac: 0 maxfr: 4863 tabn: 0 slot: 0(0x0) size/delt: 17 fb: --H-FL-- lb: 0x1 cc: 2 null: -- col 0: [ 2] c1 02 -->1 col 1: [10] 79 61 6c 6c 6f 6e 6b 69 6e 67 -->'yallonking'
--OP:11.2指的是插入行记录,如下:
--sys@ora11gr2> select utl_raw.cast_to_varchar2('79616c6c6f6e6b696e67') from dual; -- --UTL_RAW.CAST_TO_VARCHAR2('79616C6C6F6E6B696E67') ------------------------------------------------------------------------------------------------------ --yallonking -- --1 row selected. -- --sys@ora11gr2> select dump(1,16) from dual; -- --DUMP(1,16) ------------------- --Typ=2 Len=2: c1,2 -- --1 row selected.
CHANGE #6 TYP:0 CLS:31 AFN:3 DBA:0x00c000f0 OBJ:4294967295 SCN:0x0000.00117681 SEQ:1 OP:5.2 ENC:0 RBL:0 ktudh redo: slt: 0x0002 sqn: 0x00000303 flg: 0x0012 siz: 112 fbi: 0 uba: 0x00c0039c.00ea.1a pxid: 0x0000.000.00000000 --OP:5.2指的是更新回滚段头 CHANGE #7 TYP:0 CLS:31 AFN:3 DBA:0x00c000f0 OBJ:4294967295 SCN:0x0000.001176d2 SEQ:1 OP:5.4 ENC:0 RBL:0 ktucm redo: slt: 0x0002 sqn: 0x00000303 srt: 0 sta: 9 flg: 0x2 ktucf redo: uba: 0x00c0039c.00ea.1a ext: 2 spc: 4822 fbi: 0 --OP:5.4指的是跟新事务表头 CHANGE #8 TYP:0 CLS:32 AFN:3 DBA:0x00c0039c OBJ:4294967295 SCN:0x0000.00117680 SEQ:2 OP:5.1 ENC:0 RBL:0 ktudb redo: siz: 112 spc: 4936 flg: 0x0012 seq: 0x00ea rec: 0x1a xid: 0x0008.002.00000303 ktubl redo: slt: 2 rci: 0 opc: 11.1 [objn: 71689 objd: 71689 tsn: 0] Undo type: Regular undo Begin trans Last buffer split: No Temp Object: No Tablespace Undo: No 0x00000000 prev ctl uba: 0x00c0039c.00ea.0a prev ctl max cmt scn: 0x0000.00116a74 prev tx cmt scn: 0x0000.00116a83 txn start scn: 0x0000.001176c8 logon user: 0 prev brb: 12583832 prev bcl: 0 BuExt idx: 0 flg2: 0 KDO undo record: KTB Redo op: 0x03 ver: 0x01 compat bit: 4 (post-11) padding: 1 op: Z KDO Op code: DRP row dependencies Disabled xtype: XA flags: 0x00000000 bdba: 0x004138a9 hdba: 0x004138a8 itli: 1 ispac: 0 maxfr: 4863 tabn: 0 slot: 0(0x0) --OP:5.1指的是生成undo数据 END OF REDO DUMP ----- Redo read statistics for thread 1 ----- Read rate (SYNC): 7779Kb in 0.23s => 33.03 Mb/sec Total redo bytes: 8191Kb Longest record: 13Kb, moves: 6/14115 moved: 0Mb (0%) Longest LWN: 471Kb, reads: 1173 Last redo scn: 0x0000.001176d2 (1144530) Change vector header moves = 1610/25720 (6%) ----------------------------------------------
(二)分析update产生的redo
sys@ora11gr2> alter system checkpoint; System altered. sys@ora11gr2> @show_current_scn CURRENT_SCN ----------- 1145537 1 row selected. sys@ora11gr2> update yallonking set name='oraking' where id=1; 1 row updated. sys@ora11gr2> commit; Commit complete. sys@ora11gr2> alter system checkpoint; System altered. sys@ora11gr2> @show_current_scn CURRENT_SCN ----------- 1145611 1 row selected. sys@ora11gr2> @show_current_logfile; MEMBER ---------------------------------------------------------------------------------------------------- /u01/app/oracle/oradata/ora11gr2/redo01.log 1 row selected. sys@ora11gr2> @dump_logfile_by_min_max_scn /u01/app/oracle/oradata/ora11gr2/redo01.log 1145537 1145611 old 1: alter system dump logfile '&&1' scn min '&&2' scn max '&&3' new 1: alter system dump logfile '/u01/app/oracle/oradata/ora11gr2/redo01.log' scn min '1145537' scn max '1145611' System altered. TRACE_FILE_NAME ---------------------------------------------------------------------------------------------------- /u01/app/oracle/diag/rdbms/ora11gr2/ora11gr2/trace/ora11gr2_ora_21785.trc 1 row selected. 开始分析trace文件 [oracle@rhl6 dba_scripts]$ cat /u01/app/oracle/diag/rdbms/ora11gr2/ora11gr2/trace/ora11gr2_ora_21785.trc Trace file /u01/app/oracle/diag/rdbms/ora11gr2/ora11gr2/trace/ora11gr2_ora_21785.trc Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1 System name: Linux Node name: rhl6.0x64 Release: 2.6.32-71.el6.x86_64 Version: #1 SMP Wed Sep 1 01:33:01 EDT 2010 Machine: x86_64 VM name: VMWare Version: 6 Instance name: ora11gr2 Redo thread mounted by this instance: 1 Oracle process number: 26 Unix process pid: 21785, image: oracle@rhl6.0x64 (TNS V1-V3) *** 2013-12-21 18:49:53.630 *** SESSION ID:(35.41) 2013-12-21 18:49:53.630 *** CLIENT ID:() 2013-12-21 18:49:53.630 *** SERVICE NAME:(SYS$USERS) 2013-12-21 18:49:53.630 *** MODULE NAME:(sqlplus@rhl6.0x64 (TNS V1-V3)) 2013-12-21 18:49:53.630 *** ACTION NAME:() 2013-12-21 18:49:53.630 Initial buffer sizes: read 1024K, overflow 832K, change 805K Log read is SYNCHRONOUS though disk_asynch_io is enabled! DUMP OF REDO FROM FILE '/u01/app/oracle/oradata/ora11gr2/redo01.log' Opcodes *.* RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff SCNs: scn: 0x0000.00117ac1 (1145537) thru scn: 0x0000.00117b0b (1145611) Times: creation thru eternity FILE HEADER: Compatibility Vsn = 186646528=0xb200000 Db ID=119524391=0x71fcc27, Db Name='ORA11GR2' Activation ID=119541799=0x7201027 Control Seq=2793=0xae9, File size=102400=0x19000 File Number=1, Blksiz=512, File Type=2 LOG descrip:"Thread 0001, Seq# 0000000187, SCN 0x0000001151ab-0xffffffffffff" thread: 1 nab: 0xffffffff seq: 0x000000bb hws: 0x5 eot: 1 dis: 0 resetlogs count: 0x2fdc16a7 scn: 0x0000.00000001 (1) prev resetlogs count: 0x0 scn: 0x0000.00000000 Low scn: 0x0000.001151ab (1135019) 12/21/2013 04:22:12 Next scn: 0xffff.ffffffff 01/01/1988 00:00:00 Enabled scn: 0x0000.00000001 (1) 12/25/2012 10:28:49 Thread closed scn: 0x0000.00115f5d (1138525) 12/21/2013 06:00:13 Disk cksum: 0x551b Calc cksum: 0x551b Terminal recovery stop scn: 0x0000.00000000 Terminal recovery 01/01/1988 00:00:00 Most recent redo scn: 0x0000.00000000 Largest LWN: 0 blocks End-of-redo stream : No Unprotected mode Miscellaneous flags: 0x800000 Thread internal enable indicator: thr: 0, seq: 0 scn: 0x0000.00000000 Zero blocks: 0 Format ID is 2 redo log key is 21456ab701e44ef1153cb3aa1444478 redo log key flag is 5 Enabled redo threads: 1 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df0.0038 LEN: 0x00b0 VLD: 0x01 SCN: 0x0000.00117ac1 SUBSCN: 1 12/21/2013 18:46:12 (LWN RBA: 0x0000bb.00003dea.0010 LEN: 0007 NST: 0001 SCN: 0x0000.00117ac0) CHANGE #1 TYP:0 CLS:33 AFN:3 DBA:0x00c00100 OBJ:4294967295 SCN:0x0000.00117ac0 SEQ:2 OP:5.4 ENC:0 RBL:0 ktucm redo: slt: 0x0001 sqn: 0x00000301 srt: 0 sta: 9 flg: 0x2 ktucf redo: uba: 0x00c00164.0109.03 ext: 2 spc: 7768 fbi: 0 CHANGE #2 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:17.28 ENC:0 STANDBY METADATA CACHE INVALIDATION KQR INFO: [4c5c20f7, 8, 58867] KGL INFO: [e63270d7.f6f06449.1d077b12.c9b8539e, 1] [e63270d7.f6f06449.1d077b12.c9b8539e, 1] REDO RECORD - Thread:1 RBA: 0x0000bb.00003df1.0010 LEN: 0x0070 VLD: 0x06 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 (LWN RBA: 0x0000bb.00003df1.0010 LEN: 0002 NST: 0001 SCN: 0x0000.00117acd) CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 3 rdba: 0x00c00100 BFT:(1024,12583168) non-BFT:(3,256) scn: 0x0000.00117ac1 seq: 0x01 flg:0x04 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df1.0080 LEN: 0x0044 VLD: 0x02 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 1 rdba: 0x00402fe9 BFT:(1024,4206569) non-BFT:(1,12265) scn: 0x0000.00117ac1 seq: 0x01 flg:0x06 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df1.00c4 LEN: 0x0054 VLD: 0x02 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 3 rdba: 0x00c00163 BFT:(1024,12583267) non-BFT:(3,355) scn: 0x0000.00117ac0 seq: 0x05 flg:0x04 Block Written - afn: 3 rdba: 0x00c00164 BFT:(1024,12583268) non-BFT:(3,356) scn: 0x0000.00117ac0 seq: 0x04 flg:0x04 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df1.0118 LEN: 0x0044 VLD: 0x02 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 2 rdba: 0x00800ecb BFT:(1024,8392395) non-BFT:(2,3787) scn: 0x0000.00117ac1 seq: 0x01 flg:0x06 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df1.015c LEN: 0x0044 VLD: 0x02 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 1 rdba: 0x00402fc2 BFT:(1024,4206530) non-BFT:(1,12226) scn: 0x0000.00117ac1 seq: 0x01 flg:0x06 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df1.01a0 LEN: 0x0044 VLD: 0x02 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 2 rdba: 0x00800edb BFT:(1024,8392411) non-BFT:(2,3803) scn: 0x0000.00117ac1 seq: 0x01 flg:0x06 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df1.01e4 LEN: 0x0044 VLD: 0x02 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 3 rdba: 0x00c000e0 BFT:(1024,12583136) non-BFT:(3,224) scn: 0x0000.00117a48 seq: 0x01 flg:0x04 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df2.0038 LEN: 0x0044 VLD: 0x02 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 1 rdba: 0x00402ff1 BFT:(1024,4206577) non-BFT:(1,12273) scn: 0x0000.00117abf seq: 0x01 flg:0x06 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df2.007c LEN: 0x0044 VLD: 0x02 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 3 rdba: 0x00c000e7 BFT:(1024,12583143) non-BFT:(3,231) scn: 0x0000.00117a47 seq: 0x0a flg:0x04 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df2.00c0 LEN: 0x0044 VLD: 0x02 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 1 rdba: 0x0040d24d BFT:(1024,4248141) non-BFT:(1,53837) scn: 0x0000.00117ac1 seq: 0x01 flg:0x06 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df2.0104 LEN: 0x0044 VLD: 0x02 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 2 rdba: 0x0080f9df BFT:(1024,8452575) non-BFT:(2,63967) scn: 0x0000.00117ac1 seq: 0x01 flg:0x06 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df2.0148 LEN: 0x0044 VLD: 0x02 SCN: 0x0000.00117acd SUBSCN: 1 12/21/2013 18:46:49 CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 2 rdba: 0x00800ed4 BFT:(1024,8392404) non-BFT:(2,3796) scn: 0x0000.00117ac1 seq: 0x01 flg:0x06 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df3.0010 LEN: 0x0084 VLD: 0x05 SCN: 0x0000.00117aea SUBSCN: 1 12/21/2013 18:48:09 (LWN RBA: 0x0000bb.00003df3.0010 LEN: 0001 NST: 0001 SCN: 0x0000.00117ae8) CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:24.4 ENC:0 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df4.0010 LEN: 0x01d0 VLD: 0x06 SCN: 0x0000.00117b01 SUBSCN: 1 12/21/2013 18:49:07 (LWN RBA: 0x0000bb.00003df4.0010 LEN: 0001 NST: 0001 SCN: 0x0000.00117b00) CHANGE #1 MEDIA RECOVERY MARKER SCN:0x0000.00000000 SEQ:0 OP:23.1 ENC:0 Block Written - afn: 3 rdba: 0x00c005bf BFT:(1024,12584383) non-BFT:(3,1471) scn: 0x0000.00117ab3 seq: 0x02 flg:0x04 Block Written - afn: 3 rdba: 0x00c0039c BFT:(1024,12583836) non-BFT:(3,924) scn: 0x0000.00117ab1 seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c0029b BFT:(1024,12583579) non-BFT:(3,667) scn: 0x0000.00117ab5 seq: 0x03 flg:0x04 Block Written - afn: 3 rdba: 0x00c00282 BFT:(1024,12583554) non-BFT:(3,642) scn: 0x0000.00117a8e seq: 0x06 flg:0x04 Block Written - afn: 3 rdba: 0x00c0019f BFT:(1024,12583327) non-BFT:(3,415) scn: 0x0000.00117aba seq: 0x04 flg:0x04 Block Written - afn: 3 rdba: 0x00c00110 BFT:(1024,12583184) non-BFT:(3,272) scn: 0x0000.00117ab9 seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c000fe BFT:(1024,12583166) non-BFT:(3,254) scn: 0x0000.00117ab8 seq: 0x03 flg:0x04 Block Written - afn: 3 rdba: 0x00c000f0 BFT:(1024,12583152) non-BFT:(3,240) scn: 0x0000.00117ab1 seq: 0x02 flg:0x04 Block Written - afn: 3 rdba: 0x00c000d0 BFT:(1024,12583120) non-BFT:(3,208) scn: 0x0000.00117a8f seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c000c0 BFT:(1024,12583104) non-BFT:(3,192) scn: 0x0000.00117ab5 seq: 0x02 flg:0x04 Block Written - afn: 3 rdba: 0x00c000b2 BFT:(1024,12583090) non-BFT:(3,178) scn: 0x0000.00117abe seq: 0x06 flg:0x04 Block Written - afn: 3 rdba: 0x00c000b0 BFT:(1024,12583088) non-BFT:(3,176) scn: 0x0000.00117abf seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c000ac BFT:(1024,12583084) non-BFT:(3,172) scn: 0x0000.00117abc seq: 0x02 flg:0x04 Block Written - afn: 3 rdba: 0x00c000a0 BFT:(1024,12583072) non-BFT:(3,160) scn: 0x0000.00117abd seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c00090 BFT:(1024,12583056) non-BFT:(3,144) scn: 0x0000.00117abb seq: 0x01 flg:0x04 Block Written - afn: 3 rdba: 0x00c00080 BFT:(1024,12583040) non-BFT:(3,128) scn: 0x0000.00117ab3 seq: 0x02 flg:0x04 Block Written - afn: 2 rdba: 0x0080f6a4 BFT:(1024,8451748) non-BFT:(2,63140) scn: 0x0000.00117a8f seq: 0x01 flg:0x06 Block Written - afn: 2 rdba: 0x0080f680 BFT:(1024,8451712) non-BFT:(2,63104) scn: 0x0000.00117a8e seq: 0x01 flg:0x04 Block Written - afn: 2 rdba: 0x008001a6 BFT:(1024,8389030) non-BFT:(2,422) scn: 0x0000.00117a8f seq: 0x01 flg:0x06 Block Written - afn: 2 rdba: 0x0080019e BFT:(1024,8389022) non-BFT:(2,414) scn: 0x0000.00117a8f seq: 0x01 flg:0x06 Block Written - afn: 1 rdba: 0x00405971 BFT:(1024,4217201) non-BFT:(1,22897) scn: 0x0000.00117ab3 seq: 0x03 flg:0x06 Block Written - afn: 1 rdba: 0x004007f1 BFT:(1024,4196337) non-BFT:(1,2033) scn: 0x0000.00117ab5 seq: 0x03 flg:0x06 Block Written - afn: 1 rdba: 0x004007e1 BFT:(1024,4196321) non-BFT:(1,2017) scn: 0x0000.00117ab5 seq: 0x02 flg:0x06 --以上和insert一致,不再赘述 REDO RECORD - Thread:1 RBA: 0x0000bb.00003df5.0010 LEN: 0x0234 VLD: 0x0d SCN: 0x0000.00117b0b SUBSCN: 1 12/21/2013 18:49:30 (LWN RBA: 0x0000bb.00003df5.0010 LEN: 0002 NST: 0001 SCN: 0x0000.00117b0a) CHANGE #1 TYP:2 CLS:1 AFN:1 DBA:0x004138a9 OBJ:71689 SCN:0x0000.001176d2 SEQ:5 OP:11.5 ENC:0 RBL:0 KTB Redo op: 0x11 ver: 0x01 compat bit: 4 (post-11) padding: 1 op: F xid: 0x0007.01f.000002f7 uba: 0x00c000e7.00ac.17 Block cleanout record, scn: 0x0000.00117b09 ver: 0x01 opt: 0x02, entries follow... itli: 1 flg: 2 scn: 0x0000.001176d2 KDO Op code: URP row dependencies Disabled xtype: XA flags: 0x00000000 bdba: 0x004138a9 hdba: 0x004138a8 itli: 2 ispac: 0 maxfr: 4863 tabn: 0 slot: 0(0x0) flag: 0x2c lock: 2 ckix: 0 ncol: 2 nnew: 1 size: -3 -->新列值比之前的宽度少了3个 col 1: [ 7] 6f 72 61 6b 69 6e 67 -->'oraking' --OP:11.5指的update row piece CHANGE #2 TYP:0 CLS:29 AFN:3 DBA:0x00c000e0 OBJ:4294967295 SCN:0x0000.00117a48 SEQ:1 OP:5.2 ENC:0 RBL:0 ktudh redo: slt: 0x001f sqn: 0x000002f7 flg: 0x0012 siz: 144 fbi: 0 uba: 0x00c000e7.00ac.17 pxid: 0x0000.000.00000000 --更新回滚段头 CHANGE #3 TYP:0 CLS:29 AFN:3 DBA:0x00c000e0 OBJ:4294967295 SCN:0x0000.00117b0b SEQ:1 OP:5.4 ENC:0 RBL:0 ktucm redo: slt: 0x001f sqn: 0x000002f7 srt: 0 sta: 9 flg: 0x12 ktucf redo: uba: 0x00c000e7.00ac.17 ext: 0 spc: 4756 fbi: 0 --更新事务表 CHANGE #4 TYP:0 CLS:30 AFN:3 DBA:0x00c000e7 OBJ:4294967295 SCN:0x0000.00117a47 SEQ:10 OP:5.1 ENC:0 RBL:0 ktudb redo: siz: 144 spc: 4902 flg: 0x0012 seq: 0x00ac rec: 0x17 xid: 0x0007.01f.000002f7 ktubl redo: slt: 31 rci: 0 opc: 11.1 [objn: 71689 objd: 71689 tsn: 0] Undo type: Regular undo Begin trans Last buffer split: No Temp Object: No Tablespace Undo: No 0x00000000 prev ctl uba: 0x00c000e7.00ac.0d prev ctl max cmt scn: 0x0000.00116fce prev tx cmt scn: 0x0000.00117048 txn start scn: 0x0000.00000000 logon user: 0 prev brb: 12583142 prev bcl: 0 BuExt idx: 0 flg2: 0 KDO undo record: KTB Redo op: 0x03 ver: 0x01 compat bit: 4 (post-11) padding: 1 op: Z KDO Op code: URP row dependencies Disabled xtype: XA flags: 0x00000000 bdba: 0x004138a9 hdba: 0x004138a8 itli: 2 ispac: 0 maxfr: 4863 tabn: 0 slot: 0(0x0) flag: 0x2c lock: 0 ckix: 0 ncol: 2 nnew: 1 size: 3 -->增加3个宽度 col 1: [10] 79 61 6c 6c 6f 6e 6b 69 6e 67 -->'yallonking' --更新undo段 END OF REDO DUMP ----- Redo read statistics for thread 1 ----- Read rate (SYNC): 7931Kb in 0.02s => 387.26 Mb/sec Total redo bytes: 8191Kb Longest record: 13Kb, moves: 6/14559 moved: 0Mb (0%) Longest LWN: 471Kb, reads: 1280 Last redo scn: 0x0000.00117b0b (1145611) Change vector header moves = 1656/26537 (6%) ----------------------------------------------
(三)分析delete产生的redo
sys@ora11gr2> alter system checkpoint; System altered. sys@ora11gr2> @show_current_scn CURRENT_SCN ----------- 1145930 1 row selected. sys@ora11gr2> delete from yallonking where id=1; 1 row deleted. sys@ora11gr2> commit; Commit complete. sys@ora11gr2> alter system checkpoint; System altered. sys@ora11gr2> @show_current_scn CURRENT_SCN ----------- 1145970 1 row selected. sys@ora11gr2> @show_current_logfile; MEMBER ---------------------------------------------------------------------------------------------------- /u01/app/oracle/oradata/ora11gr2/redo01.log 1 row selected. sys@ora11gr2> @dump_logfile_by_min_max_scn /u01/app/oracle/oradata/ora11gr2/redo01.log 1145930 1145970 old 1: alter system dump logfile '&&1' scn min '&&2' scn max '&&3' new 1: alter system dump logfile '/u01/app/oracle/oradata/ora11gr2/redo01.log' scn min '1145930' scn max '1145970' System altered. TRACE_FILE_NAME ---------------------------------------------------------------------------------------------------- /u01/app/oracle/diag/rdbms/ora11gr2/ora11gr2/trace/ora11gr2_ora_21858.trc 1 row selected. 开始分析trace文件 截取有用的部分 REDO RECORD - Thread:1 RBA: 0x0000bb.00004720.0010 LEN: 0x0224 VLD: 0x0d SCN: 0x0000.00117c72 SUBSCN: 1 12/21/2013 19:02:08 (LWN RBA: 0x0000bb.00004720.0010 LEN: 0002 NST: 0001 SCN: 0x0000.00117c70) CHANGE #1 TYP:2 CLS:1 AFN:1 DBA:0x004138a9 OBJ:71689 SCN:0x0000.00117b0b SEQ:2 OP:11.3 ENC:0 RBL:0 KTB Redo op: 0x11 ver: 0x01 compat bit: 4 (post-11) padding: 1 op: F xid: 0x0005.012.000002ff uba: 0x00c0029b.00b0.3a Block cleanout record, scn: 0x0000.00117c71 ver: 0x01 opt: 0x02, entries follow... itli: 2 flg: 2 scn: 0x0000.00117b0b KDO Op code: DRP row dependencies Disabled xtype: XA flags: 0x00000000 bdba: 0x004138a9 hdba: 0x004138a8 itli: 1 ispac: 0 maxfr: 4863 tabn: 0 slot: 0(0x0) --OP:11.3指的是drop row piece CHANGE #2 TYP:0 CLS:25 AFN:3 DBA:0x00c000c0 OBJ:4294967295 SCN:0x0000.00117c3d SEQ:2 OP:5.2 ENC:0 RBL:0 ktudh redo: slt: 0x0012 sqn: 0x000002ff flg: 0x0012 siz: 184 fbi: 0 uba: 0x00c0029b.00b0.3a pxid: 0x0000.000.00000000 --更新回滚段头 CHANGE #3 TYP:0 CLS:25 AFN:3 DBA:0x00c000c0 OBJ:4294967295 SCN:0x0000.00117c72 SEQ:1 OP:5.4 ENC:0 RBL:0 ktucm redo: slt: 0x0012 sqn: 0x000002ff srt: 0 sta: 9 flg: 0x2 ktucf redo: uba: 0x00c0029b.00b0.3a ext: 4 spc: 850 fbi: 0 --更新事务表 CHANGE #4 TYP:0 CLS:26 AFN:3 DBA:0x00c0029b OBJ:4294967295 SCN:0x0000.00117c3d SEQ:2 OP:5.1 ENC:0 RBL:0 ktudb redo: siz: 184 spc: 1036 flg: 0x0012 seq: 0x00b0 rec: 0x3a xid: 0x0005.012.000002ff ktubl redo: slt: 18 rci: 0 opc: 11.1 [objn: 71689 objd: 71689 tsn: 0] Undo type: Regular undo Begin trans Last buffer split: No Temp Object: No Tablespace Undo: No 0x00000000 prev ctl uba: 0x00c0029b.00b0.38 prev ctl max cmt scn: 0x0000.0011754c prev tx cmt scn: 0x0000.0011754d txn start scn: 0x0000.00000000 logon user: 0 prev brb: 12583230 prev bcl: 0 BuExt idx: 0 flg2: 0 KDO undo record: KTB Redo op: 0x04 ver: 0x01 compat bit: 4 (post-11) padding: 1 op: L itl: xid: 0x0008.002.00000303 uba: 0x00c0039c.00ea.1a flg: C--- lkc: 0 scn: 0x0000.001176d2 KDO Op code: IRP row dependencies Disabled xtype: XA flags: 0x00000000 bdba: 0x004138a9 hdba: 0x004138a8 itli: 1 ispac: 0 maxfr: 4863 tabn: 0 slot: 0(0x0) size/delt: 14 fb: --H-FL-- lb: 0x0 cc: 2 null: -- col 0: [ 2] c1 02 -->1 col 1: [ 7] 6f 72 61 6b 69 6e 67 -->'oraking' --写undo数据 END OF REDO DUMP ----- Redo read statistics for thread 1 ----- Read rate (SYNC): 9104Kb in 0.06s => 148.19 Mb/sec Total redo bytes: 9215Kb Longest record: 23Kb, moves: 7/15608 moved: 0Mb (0%) Longest LWN: 471Kb, reads: 1309 Last redo scn: 0x0000.00117c72 (1145970) Change vector header moves = 1800/28764 (6%) ----------------------------------------------
比较各个操作产生redo情况
插入: ----- Redo read statistics for thread 1 ----- Read rate (SYNC): 7779Kb in 0.23s => 33.03 Mb/sec Total redo bytes: 8191Kb Longest record: 13Kb, moves: 6/14115 moved: 0Mb (0%) Longest LWN: 471Kb, reads: 1173 Last redo scn: 0x0000.001176d2 (1144530) Change vector header moves = 1610/25720 (6%) ---------------------------------------------- 更新: ----- Redo read statistics for thread 1 ----- Read rate (SYNC): 7931Kb in 0.02s => 387.26 Mb/sec Total redo bytes: 8191Kb Longest record: 13Kb, moves: 6/14559 moved: 0Mb (0%) Longest LWN: 471Kb, reads: 1280 Last redo scn: 0x0000.00117b0b (1145611) Change vector header moves = 1656/26537 (6%) ---------------------------------------------- 删除: ----- Redo read statistics for thread 1 ----- Read rate (SYNC): 9104Kb in 0.06s => 148.19 Mb/sec Total redo bytes: 9215Kb Longest record: 23Kb, moves: 7/15608 moved: 0Mb (0%) Longest LWN: 471Kb, reads: 1309 Last redo scn: 0x0000.00117c72 (1145970) Change vector header moves = 1800/28764 (6%) ----------------------------------------------