Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2796417
  • 博文数量: 389
  • 博客积分: 4177
  • 博客等级: 上校
  • 技术积分: 4773
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-16 23:29
文章分类

全部博文(389)

分类: Oracle

2014-07-31 22:12:16

                               数据库处于HOT BACKUP的REDO产生 
           
       有很多朋友经常担心oracle处于hot backup模式下会产生大量redo,这是由于在hot backup期间,
oracle会把修改的块写到redo log中,所以会导致redo log文件变得很大,使redo logfile切换变得很
频繁,来看一个例子(环境:rhel 5.8, oracle 12c)     
               

SQL> create table t1 ( a int);

Table created.

SQL> insert into t1 values(10);

1 row created.

SQL> commit;

Commit complete.


SQL> select object_id,owner from dba_objects where object_name='T1';

 OBJECT_ID
----------
OWNER
--------------------------------------------------------------------------------
     92888
SYS

SQL> alter system dump logfile '/usr/oracle/oradata/t2/redo02.log';

System altered.


CHANGE #5 CON_ID:1 TYP:0 CLS:1 AFN:1 DBA:0x00418681 OBJ:92888 SCN:0x0000.0023bbe7 SEQ:3 OP:11.2 ENC:0 RBL:0 FLG:0x0000
KTB Redo
op: 0x01  ver: 0x01
compat bit: 4 (post-11) padding: 1
op: F  xid:  0x000a.00c.00000657    uba: 0x01000df9.012d.33
KDO Op code: IRP row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x00418681  hdba: 0x00418680
itli: 1  ispac: 0  maxfr: 4863
tabn: 0 slot: 0(0x0) size/delt: 6
fb: --H-FL-- lb: 0x1  cc: 1
null: -
col  0: [ 2]  c1 0b (十进制数据10)
CHANGE #6 CON_ID:1 TYP:0 CLS:35 AFN:4 DBA:0x01000110 OBJ:4294967295 SCN:0x0000.0023bbd0 SEQ:1 OP:5.2 ENC:0 RBL:0 FLG:0x0000
ktudh redo: slt: 0x000c sqn: 0x00000657 flg: 0x0052 siz: 112 fbi: 0
            uba: 0x01000df9.012d.33    pxid:  0x0000.000.00000000        pdbid:1

通过dump redo logfile看出,当oracle没在hot backup模式下的时候,正常初始化块,然后写入数据


 现在把数据库置于hot backup模式.

SQL> alter database begin backup;

Database altered.

SQL> insert into t1 values(10);

1 row created.

SQL> commit;

Commit complete.


通过dump redo logfile看到,当处于hot backup时,对块进行修改之前,会把块dump到redo log文件中。

REDO RECORD - Thread:1 RBA: 0x00002c.00000572.00a4 LEN: 0x202c
VLD: 0x01 CON_UID: 1
SCN: 0x0000.0023bccf SUBSCN:  1 07/31/2014 13:44:56

CHANGE #1 CON_ID:1 TYP:3 CLS:1 AFN:1 DBA:0x00418681 OBJ:92888 SCN:0x0000.0023bbe7 SEQ:5 OP:18.1
 ENC:0 RBL:0 FLG:0x0000
Log block image redo entry
Dump of memory from 0x00002B1F23025028 to
0x00002B1F23027010
2B1F23025020                   00000001 00016AD8         
[.....j..]
2B1F23025030 0023BBE5 FFFF0000 00030002 00000000 
[..#.............]
2B1F23025040 000C000A 00000657 01000DF9 0033012D 
[....W.......-.3.]
2B1F23025050 00002001 0023BBE7 00000000 00000000 
[. ....#.........]
2B1F23025060 00000000 00000000 00000000 00000000
 [................]
2B1F23025070 00010100 0014FFFF 1F831F9A 00001F83
 [................]
2B1F23025080 1F9A0001 00000000 00000000 00000000 
[................]
2B1F23025090 00000000 00000000 00000000 00000000 
[................]
        Repeat 502 times
2B1F23027000 00000000 00000000 012C0000 0BC10201
 [..........,.....]
Dump of memory from 0x00002B1F23027010 to 0x00002B1F23027011
2B1F23027010 00400F06               
             [..@.]  

接下再是修改的record change

op: Z
KDO Op code: DRP row dependencies Disabled
  xtype: XA
flags: 0x00000000  bdba: 0x00418681  hdba: 0x00418680
itli: 2
 ispac: 0  maxfr: 4863
tabn: 0 slot: 1(0x1)

CHANGE #3 CON_ID:1
TYP:2 CLS:1 AFN:1 DBA:0x00418681 OBJ:92888 SCN:0x0000.0023bbe7
SEQ:5 OP:11.2 ENC:0 RBL:0 FLG:0x0000
KTB Redo
op: 0x01  ver: 0x01 

compat bit: 4 (post-11) padding: 1
op: F  xid:  0x0007.01e.000006c6   
uba: 0x01000d04.017b.26
KDO Op code: IRP row dependencies Disabled
 
xtype: XA flags: 0x00000000  bdba: 0x00418681  hdba: 0x00418680
itli: 2  ispac: 0
 maxfr: 4863
tabn: 0 slot: 1(0x1)
 size/delt: 6
fb: --H-FL-- lb: 0x2  cc: 1
null: -
col  0:
 [ 2]  c1 0b


第三次insert数据,再次dump logfile

SQL> conn / as sysdba;
Connected.
SQL> insert into t1 values(11);

1 row created.

SQL> commit;

Commit complete.


CHANGE #3 CON_ID:1 TYP:2 CLS:1 AFN:1 DBA:0x00418681 OBJ:92888 SCN:0x0000.0023bcd1
SEQ:1 OP:11.2 ENC:0 RBL:0 FLG:0x0000
KTB Redo
op: 0x11  ver: 0x01 

compat bit: 4 (post-11) padding: 1
op: F  xid:  0x0004.01b.0000066b  
 uba: 0x01000e15.013f.12
Block cleanout record, scn:  0x0000.0023bdf9 ver: 0x01
 opt: 0x02, entries follow...
  itli: 1  flg: (opt=2 whr=1)  scn: 0x0000.0023bbe7
 
 itli: 2  flg: (opt=2 whr=1)  scn: 0x0000.0023bcd1
KDO Op code: IRP row dependencies Disabled
 
 xtype: XA flags: 0x00000000  bdba: 0x00418681  hdba: 0x00418680
itli: 1  ispac: 0  maxfr: 4863
tabn: 0
 slot: 2(0x2) size/delt: 6
fb: --H-FL-- lb: 0x1  cc: 1

null: -

col  0: [ 2]  c1 0c (表示12)

通过dump logfile文件发现,在这条记录之前没有任何该块的dump了.
实验表明,hot backup对于redo 的产生是有一定的增加。当在第一次修改块的时候,
会把该块dump到redo log中,后续对再对该数据块的修改不进行dump到redo中了.

 


 

阅读(2205) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~