oracle实验记录 (oracle 详细分析redo(1))

redo详细分析

运行机制结构:

redo log buffer 循环使用在SGA中。存redo entries

change vector用来描述对db 中任何单个block所做的一次改动:存版本号(可以让block始终能够体现当前的最新状态),事务操作代码,被改动的数据块地址等,在建立change vector时oracle会从data block copy其版本号,在recover时 oracle应用change vecotr并将改动应用于相应的block后,被恢复的数据块版本号加一(临时段的数据块不会生成change vector)
多个change vector按顺序组合在一起,从而完成一次改动,oracle叫这组改动为redo record(也可以叫 redo entries),redo record用来描述对db的一个原子改动(应用redo record 中 change vector要么全部成功,要么全部失败,不会存在部分成功 部分失败情况)

 


redo entries内容被oracle process 从PGA copy到SGA REDO LOG BUFFER,redo entries在内存中是占用连续的顺序的空间,lgwr不断将redo log buffer中内容,写入redo file
由于user process 向redo log buffer写数据,所以需要latch保护
redo copy latch:写redo 到redo log buffer
redo allocation latch:控制log buffer分配
使用这2个latch
进程修改数据时产生redo,此时redo存pga中,将PGA中redo copy到 redo log buffer 要redo copy latch,lgwr只有等待进程COPY 完成才能把目标log buffer block写入disk

NAME                           VALUE                     ISDEFAULT ISMOD
            ISADJ
------------------------------ ------------------------- --------- ----------------
---------------- --------------------------------
KSPPDESC
-----------------------------------------------------------------------------------
-------------------------------------------------
_log_simultaneous_copies       4                         TRUE      FALSE
            FALSE
number of simultaneous copies into redo buffer(# of copy latches)

redo copy latch数量 defalut cpu_count*2

SQL> show parameter cpu

NAME                                 TYPE                             VALUE
------------------------------------ -------------------------------- -------------
-----------------
cpu_count                            integer                          2

SQL> select name,gets,immediate_gets from v$latch_children where name='redo copy';

NAME                                 GETS IMMEDIATE_GETS
------------------------------ ---------- --------------
redo copy                              10              0
redo copy                              10              0
redo copy                              10              0
redo copy                              10            943

SQL> select name,gets,immediate_gets from v$latch where name='redo copy';

NAME                                 GETS IMMEDIATE_GETS
------------------------------ ---------- --------------
redo copy                              40            943

GETS NUMBER    Number of times the latch was requested in willing-to-wait mode
MISSES NUMBER  Number of times the latch was requested in willing-to-wait mode and the requestor had to wait
SLEEPS NUMBER  Number of times a willing-to-wait latch request resulted in a session sleeping while waiting for the latch
IMMEDIATE_GETS NUMBER Number of times a latch was requested in no-wait mode
IMMEDIATE_MISSES NUMBER Number of times a no-wait latch request did not succeed (that is, missed)

redo copy latch 与redo allocation latch 合作
在将PGA中redo copy到 log buffer时,获取redo copy latch,获取后接着获取redo allocation latch 分配redo log buffer空间,分配后释放redo allocation latch,然后server process 将PGA中redo信息 COPY 到redo log buffer,OK 后redo copy latch释放


例 一个UPDATE的过程
1.server process 搜索buffer cache中是否有update要更新的block(内存中叫buffer),没有从disk读入buffer cache,用EXCLUSIVE PING住
2.server process 构造一组change vector来记录对数据块的改动(此时放PGA中),这组change vector组成 redo record
3.用redo record大SIZE 判断需要多少redo log buffer空间
4.判断current scn,将其存到redo record(不同的redo record可能会共享同样的SCN值)
5.获得redo copy latch,接着获得redo allocation latch
6.查看当前是否有其它process比当前持有的SCN 更高的SCN值,有的话生成一个新SCN,替换第4步中的SCN
7.判断是否有足够的redo log buffer空间(逻辑上判断比较复杂) 具体如下:
如果redo log buffer没有足够空间,释放redo copy latch,redo allocation latch,释放后如果此时有其它进程或条件出发了lgwr则要等待lgwr完成,如果此时lgwr没启动,则触发lgwr 启动(需要reodo writing latch,从LOG BUFFER 把redo record写入current redo log file中时 LGWR进程会一直占着这个LATCH,防止其他process同时触发lgwr,其它process要尝试获得该latch必须等待,还会获得redo allocation latch 防止有新的change vector继续写入log buffer,造成LGWR无法确定应该写多少redo),当没有足够空间时,释放完redo copy/allocation latch后,会立刻尝试获取redo writing latch 获取不到 就表明lgwr被其他process启动了,等待,继续尝试,获取到后会先检查log buffer是否有空间了(因为前面LGWR 可能释放了大量redo log buffer空间)此时要是有空间了 释放redo writing latch,然后获得redo copy/allocation latch,没空间的话触发lgwr,并且释放redo writing latch(把这个latch给了lgwr).如果没有空间,且lgwr 将redo log buffer redo record 写入online current redo logfile时 redo logfile空间不足不够写入时,则process会检查是否有其它process启动了switch logfile,如果没有则触发switch logfile,有其他进程启动了,则当前进程等待,switch logfile 后,继续让lgwr写入redo log buffer .(注意switch log时候 禁止生成redo)

如果redo log buffer有足够的空间,则分配空间 释放redo allocation latch,然后把change vector从PGA COPY  reod log buffer,把redo record 对应在buffer cache中修改的block 挂到ckptq(checkpoint queue)上去(等dbwr写入)然后释放redo copy latch.

8.检查写完后的redo log buffer ,redo record是否达到threadshold,到了则触发lgwr
9.**********更新buffer cache 中block********************


具体过程实验:


SQL> show user
USER 为 "XH"
SQL> create table t1(id int, a char(2000),b char(2000), c char(2000));

表已创建。

SQL> insert into t1 values(1,'a','a','a');

已创建 1 行。

SQL> insert into t1 values(2,'b','b','b');

已创建 1 行。

SQL> commit;

 

SQL> show user;
USER 为 "SYS"
SQL>


SQL> select file#,block# from (select dbms_rowid.rowid_relative_fno(rowid) file#
,dbms_rowid.rowid_block_number(rowid) block# from xh.t1);

     FILE#     BLOCK#
---------- ----------
         4       1326
         4       1327

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

DATA_OBJECT_ID OWNER
-------------- ------------------------------
         54369 XH
SQL> alter system flush buffer_cache;

系统已更改。

SQL> select file#,block#,dirty from v$bh where bjd=54369;

     FILE#     BLOCK# D
---------- ---------- -
         4       1325 N
         4       1328 N
         4       1323 N
         4       1326 N
         4       1321 N
         4       1324 N
         4       1327 N
         4       1322 N

已选择8行。


SQL> update t1 set a='aa' where id=1;(user xh )

已更新 1 行。


SQL> select file#,block#,dirty from v$bh where bjd=54369;(user sys)

     FILE#     BLOCK# D
---------- ---------- -
         4       1325 N
         4       1328 N
         4       1323 N
         4       1326 N
         4       1326 Y*****************
         4       1324 N
         4       1327 N

已选择7行。

SQL> select  XIDUSN,XIDSLOT,XIDSQN,UBAFIL,UBABLK from v$transaction;(user sys)

    XIDUSN    XIDSLOT     XIDSQN     UBAFIL     UBABLK
---------- ---------- ---------- ---------- ----------
         4         20       1130          2         71

oracle 找出id=1的 block file4,block 1326放入buffer_cache ,并且找到一个可用的undo块,将 旧值放入undo block(71) 产生重做记录,新值放入新data block(1326)产生重做记录

 


SQL> update xh.t1 set a='aaa' where id=2;(另一个 sesssion)

已更新 1 行。

SQL> select file#,block#,dirty from v$bh where bjd=54369;

     FILE#     BLOCK# D
---------- ---------- -
         4       1325 N
         4       1328 N
         4       1323 N
         4       1326 N
         4       1326 Y
         4       1326 N
         4       1326 N
         4       1324 N
         4       1327 N
         4       1327 Y~~~~~

已选择10行。
SQL> select  XIDUSN,XIDSLOT,XIDSQN,UBAFIL,UBABLK from v$transaction;

    XIDUSN    XIDSLOT     XIDSQN     UBAFIL     UBABLK
---------- ---------- ---------- ---------- ----------
         4         20       1130          2         71~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~叫t1
         2         28       1421          2         28~~~~~~~~~~~新多的update xh.t1这个事务(起名叫t2)
一样产生redo record
此时事务t1 commit LGWR 会将 事务T2的redo 一起写入 log file


SQL> select name,usn from v$rollname where usn in (4,2);

NAME                                  USN
------------------------------ ----------
_SYSSMU2$                               2
_SYSSMU4$                               4

 

 

SQL> ALTER SYSTEM DUMP UNDO HEADER '_SYSSMU2$';

系统已更改。

SQL> ALTER SYSTEM DUMP UNDO HEADER '_SYSSMU4$';

系统已更改。

 


查看trace
'_SYSSMU2$的dump
  TRN TBL::
 
  index  state cflags  wrap#    uel         scn            dba            parent-xid    nub     stmt_num    cmt
  ------------------------------------------------------------------------------------------------
0x1c   10    0x80  0x058d  0x0000  0x0000.004befdc  0x0080001c  0x0000.000.00000000  0x00000001   0x00000000  0
0x1c是slot (28)v$transaction.XIDSLOT ,10 代表活动的

SQL> select to_number('1c','xxxxxx') from dual;

TO_NUMBER('1C','XXXXXX')
------------------------
                      28

 

 

 

'_SYSSMU4$的dump

TRN TBL::
 
  index  state cflags  wrap#    uel         scn            dba            parent-xid    nub     stmt_num    cmt
  ------------------------------------------------------------------------------------------------

   0x14   10    0x80  0x046a  0x0001  0x0000.004beea0  0x00800047  0x0000.000.00000000  0x00000001   0x00000000  0

 

SQL> select to_number('14','xxxxxx') from dual;

TO_NUMBER('14','XXXXXX')
------------------------
                      20

0x1c是slot (20) v$transaction.XIDSLOT ,10 代表活动的


SQL> commit;(USER XH)

提交完成。

SQL> select  XIDUSN,XIDSLOT,XIDSQN,UBAFIL,UBABLK from v$transaction;

    XIDUSN    XIDSLOT     XIDSQN     UBAFIL     UBABLK
---------- ---------- ---------- ---------- ----------
         2         28       1421          2         28


那么刚才t1事务结束,并且触发lgwr,连同T2的redo一起写入redo log file

 


SQL> ALTER SYSTEM DUMP UNDO HEADER '_SYSSMU4$';

系统已更改。


 TRN TBL::
 
  index  state cflags  wrap#    uel         scn            dba            parent-xid    nub     stmt_num    cmt
  ------------------------------------------------------------------------------------------------

  0x1c    9    0x00  0x046a  0x0007  0x0000.004bec85  0x00800046  0x0000.000.00000000  0x00000001   0x00000000  1256274692

state 9表示已经 提交.

 

 

补充:快速获取 当前session的 dump trace

SQL> conn xh/a831115
已连接。
SQL>  ALTER SYSTEM DUMP UNDO HEADER '_SYSSMU2$';

系统已更改。

SQL> select c.value || '/' || d.instance_name ||
  2   '_ora_' || a.spid || '.trc' trace
  3   from v$process a, v$session b, v$parameter c, v$instance d
  4   where a.addr = b.paddr
  5   and b.audsid = userenv('sessionid')
  6   and c.name = 'user_dump_dest'
  7  /

TRACE
--------------------------------------------------------------------------------

F:\ORACLE\PRODUCT\10.2.0\ADMIN\XHTEST\UDUMP/xhtest_ora_3920.trc

 

 

LGWR写时具体过程:
1.先尝试获取redo writing latch,确保其他process不会继续触发lgwr
2.获取redo allocation latch(public redo allocation latch),防止有新的change vector继续写入log buffer,造成LGWR无法确定应该写多少redo.
3.LGWR确定写的范围(从上次lgwr启动所写的最后一个日志块到这个时间点时的最后一个被使用的所有写满or未写满的日志块)此时前台process仍可以向这个范围内的redo block(buffer)写内容(从PGA写)所以lgwr不阻挨其它进程获得redo copy latch(既不阻止其它进程向log buffer 中可用块中写change vector)
4.确定redo block(buffer)后生成新SCN号
5.LGWR释放redo allocation latch与redo writing latch
6.LGWR需要等待 其它进程对要写入日志文件的block的更新操作完成(pga-log buffer的操作),通过判断日志block(buffer)上的redo copy latch是否都释放.
7.将第4步scn号copy到要写入logfile的log buffer的块头里,然后触发物理的写操作,将这些待写日志块写入redo file

 

SQL> select total_waits,time_waited,average_wait,time_waited/total_waits as avg fro
m v$system_event where event = 'log file parallel write';

TOTAL_WAITS TIME_WAITED AVERAGE_WAIT        AVG
----------- ----------- ------------ ----------
       1313          54          .04  .04112719

time_waited/total_waits:表示平均lgwr写入完成时间 若>1表示写入过慢 主要表现了lgwr的 io性能

 

 

 

关于log buffer 信息
SQL> col name format a30
SQL> select name,value from v$sysstat where name like '%redo%';

NAME                                VALUE
------------------------------ ----------
redo synch writes                    2481
redo synch time                        15
redo blocks read for recovery          48
redo entries                         6997
redo size                         3392844
redo buffer allocation retries          0
redo wastage                       378756
redo writer latching time               0
redo writes                          1337
redo blocks written                  7609
redo write time                        60

NAME                                VALUE
------------------------------ ----------
redo log space requests                 0
redo log space wait time                0
redo log switch interrupts              0
redo ordering marks                   132
redo subscn max counts                  0

已选择16行。

以上是log buffer的统计信息

redo writes表示写了多少次(1337次),redo blocks written 表示总共写了多少日志块(7609块),redo write time表示写入日志文件用了多少时间(10毫秒),这3个是在lgwr写完redo record到logfile 后更新.
redo size表示产生了多少重做记录(字节),redo entries也表示产生多少重做记录(个数为单位),从PGA COPY到SGA LOG BUFFER前更新

redo wastage:表示log buffer中日志块写入redo log file时,没有被利用的空间数量(字节单位)

 


redo log space wait time表示对online redo log file 发出请求空间后等待时间,redo log space requests 表示对online redo logfile 发出请求空间的次数. 它们的值只在进程在发出请求logfile space没有请求到空间的时候才增加,然后请求的进程等待switch logfile,如果没有手动alter system switch logfile,redo log space requests 可以代表switch logfile次数


redo buffer allocation retries :表示再次尝试从log buffer中分空间的次数(最好为0),process第一次没请求成功 会触发LGWR 然后等待完成或其它PROCESS 已经触发而 这个进程等待lgwr完成,完成后再次尝试从log buffer中分配空间
用 redo buffer allocation retries和redo entries可以计算出从PGA copy change vector到SGA LOG BUFFER 时必须等待的重做记录的数量所占的比例
最好为0 或<1%如果>1%且不断边大 说明从PGA copy change vector到SGA LOG BUFFER时必须等待log buffer空的日志块,可以考虑加大log buffer or  提高lgwr写效率


SQL> select a.value/b.value from v$sysstat a , v$sysstat b where a.name='redo buffe
r allocation retries' and b.name='redo entries';

A.VALUE/B.VALUE
---------------
              0

 

redo synch writes:提交刷新log buffer的次数   redo synch time:COMMIT 书信log buffer花费的时间(10毫秒),用户commit时增加.

 

redo copy latch:将PGA中change vector写入SGA LOG BUFFER中需要
redo allocation latch:在log buffer中分配空间时需要
redo writing latch:当用户COMMITor系统触发LGWR 写REDO FILE时 都会获得该latch,如果redo wrting latch 竞争太多,可能代表用户过多commit

 


关于redo wastage:
LGWR commonly writes up to and including the current log buffer block, which is normally only partially full. The SGA variable containing the index into the log buffer for redo generation is then advanced to the beginning of the next log buffer block before LGWR releases the redo allocation latch prior to writing. In this way, some space is left unused in the last log block of most redo writes. The number of bytes skipped is accumulated in the redo wastage statistic. The following diagram illustrates redo wastage within the first few blocks of a sample Oracle redo log file.

Redo wastage is not a problem. Indeed, it benefits performance by preserving LGWR's sequential I/O pattern. However, high redo wastage is a symptom of a very active LGWR, and that might be a problem. LGWR is expected to be highly active in many instances, but it can be overactive if the log buffer (more correctly, the _log_io_size) is too small, or if the commit rate is too high. If LGWR is overactive, it will place unnecessary load on the redo latches, and on the I/O subsystem. The operating system may also degrade LGWR's execution priority.

 

产生的 redo先从PGA写入 redo buffer中 ,然后 由lgwr写入redo logfile,redo block一般是 512字节(不同的OS不一样),redo block header是 16字节 ,那么oracle中redo block可使用的空间是 512-16字节,逻辑上 redo file 由redo record组成(由change vector组成)lgwr进程 从 log buffer将redo写入logfile时将产生一些未使用的 空间,主要 因为lgwr写时要释放redo allocation latch,但事务是不停止的,不断产生新的redo,这些redo要不停的写入log buffer,所以oracle在 释放 redo allocation latch之前必须给随后的redo写 一个 新的buffer的 起始地址,存在sga fixed area,中的 一个INDEX中 ,这个 INDEX 告诉oracle redo buffer写的 起始位置,当分配这个INDEX时,oracle SKIPPED 当前已使用的 块,在下一个没有使用的 块上分配,这部分跳过的size叫redo wastage,这种方法模式会让大部分写redo到 logfile 时最后一个redo block中一部分空间还未使用

LGWR是正块的写一个块是 512-16字节,假如用了 100K 就写入redofile了 ,这样512-16-100 就 等于未使用但也 写入redofile了,就是浪费的空间

Redo wastage并不是大问题,如果过多表示lgwr启动过多造成需要多的latch,也有可能是commit过于频繁

SQL> select * from v$sga;

NAME                      VALUE
-------------------- ----------
Fixed Size              1248576~~~~~~~~~~~INDEX存这里
Variable Size         113246912
Database Buffers      167772160
Redo Buffers            7139328

SQL> select max(lebsz) from x$kccle;

MAX(LEBSZ)
----------
       512~~~~~~~~~~~~redo block大小


  1* select round((a.redosize+b.redowast)/c.redoblks) + 16 as redo_block_size fr
om (select value redosize from v$sysstat where name='redo size') a,(select value
 redowast from v$sysstat where name='redo wastage') b,(select value redoblks fro
m v$sysstat where name='redo blocks written') c
SQL> /

REDO_BLOCK_SIZE
---------------
            512
计算redo block size公式:16+(redosize+redowast)/redoblks=16+(产生多少字节+浪费多少字节)/写了多少日志块

 


oracle10G R2 默认提供了 20 redo allocation latch

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> col name format a20
SQL> select name,gets,misses,misses/gets from v$latch where name='redo allocation';


NAME                       GETS     MISSES MISSES/GETS
-------------------- ---------- ---------- -----------
redo allocation             321          0           0
SQL> select name,gets,misses,misses/gets from v$latch_children where name='redo all
ocation';

NAME                       GETS     MISSES MISSES/GETS
-------------------- ---------- ---------- -----------
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0

NAME                       GETS     MISSES MISSES/GETS
-------------------- ---------- ---------- -----------
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation               5          0           0
redo allocation              19          0           0
redo allocation              45          0           0
redo allocation              62          0           0
redo allocation             116          0           0

已选择20行。


SQL> select name,gets,misses,misses/gets from v$latch where name='redo writing';

NAME             GETS     MISSES MISSES/GETS
---------- ---------- ---------- -----------
redo writi      11396          3   .00026325

 

可以看到redo writing latch都是愿意等待模式,如果MISSES/GETS >1%(0.01)那么可以认为存在latch 竞争

SQL> select name,gets,immediate_gets from v$latch_children where name='redo writing
';

未选定行
没有子 latch

 

关于redo中子池,与shared pool类似
每个子redo buffer 都对应一个redo allocation latch(shared pool每个SUB POOL 对应一个shared pool latch)


NAME                           VALUE                     ISDEFAULT ISMOD
            ISADJ
------------------------------ ------------------------- --------- ---------------
---------------- --------------------------------
KSPPDESC
----------------------------------------------------------------------------------
-------------------------------------------------
_log_parallelism               1                         TRUE      FALSE
            FALSE
Number of log buffer strands

_log_parallelism  控制是否有多个redo log buffer,且每个对应独立的redo allocation latch,提高并发性,多个redo log buffer叫做public redo log strands(9i)

(9I中不是隐藏参数,10G中成为隐藏参数了) ,下面两个参数允许动态调整,_log_parallelism_max 比_log_parallelism  大时,oracle会自动选择并行度(public redo log strands)

 

_log_parallelism_dynamic       TRUE                      TRUE      FALSE
            FALSE
Enable dynamic strands

_log_parallelism_max           2                         TRUE      FALSE
            FALSE

 

注意当 _log_parallelism>1那么logmnr将无法使用 ora-01374

10GR2 orcle引入private redolog strands ,会从shared pool分配大量小内存(64-128KB),有地理的 redo allocation latch保护,一些特定小事务会在开始时绑定在独立且空闲的private redo log strands中,change vector生成后 不在存pga而是存private redolog strands,这样不从PGA COPY 到 SGA LOG BUFFER 就不需要redo copy latch,所以private redo log strands也叫zero-copy redo
写入redo log file时候 oracle lGWR后台进程 将private redolog strands&public redo log strands都写入redo log file,
lgwr  redo flush时,所有public redo allocation latch 都会被获取(避免在分配redo buffer空间 造成 lgwr不能确定写的 范围)所有public strands 的 redo copy latch需要检查,包含活动事务的private strands要被持有(oracle仍允许pga向 log buffer 中 可用空间 copy  change vector)
SQL> select * from v$sgastat where name='private strands';

POOL         NAME                            BYTES
------------ -------------------------- ----------
shared pool  private strands               1198080


相关参数:
log_private_mul               5                         TRUE      FALSE      FA
SE
rivate strand multiplier for log space preallocation

log_private_parallelism       FALSE                     TRUE      FALSE      FA
SE
umber of private log buffer strands for zero-copy redo

log_private_parallelism_mul   10                        TRUE      FALSE      FA
SE
ctive sessions multiplier to deduce number of private strands

 


alert.log中
Private strand flush not complete
  Current log# 1 seq# 44 mem# 0: D:\ORACLE\PRODUCT\10.2.0\ORADATA\XH\REDO01.LOG
Thread 1 advanced to log sequence 45
表示log buffer到redo log file还没有完成(LGWR 写如redo log file)


SQL> select name from v$event_name where name like 'log%';

NAME
----------------------------------------------------------------
log file sequential read
log file single write
log file parallel write
log buffer space
log file switch (checkpoint incomplete)
log file switch (private strand flush incomplete)
log file switch (archiving needed)
log file switch completion
log file sync
log switch/archive
log file switch (clearing log file)

NAME
----------------------------------------------------------------
log write(odd)
log write(even)

已选择13行。

log file switch (private strand flush incomplete)  反映在 evnet 里 就是这个事件


redo file切换(SWITCH LOG FILE)
一个online redo log file写完后,要转换到另外一个redo file
基本过程:
1.从controlfile中取得下一个可用online redo file
2.记录写入current online redo log file的最后一个redo block的SCN (HIGHT SCN),关闭current online
redo log file
3.增加SCN,再次操作CONTROLFILE,将下一个online redo log file,标记为current,还需要判断前一个current
redo file中是否有未写入disk的dirty buffer,如果有的话标记为active(虽然已经switch logfile了,但是是一个
这种检查点级别低,且还没到INCREMANETAL CHECKPOINT的条件比如dirty buffer少,所以swtich logfile后,仍然有没有
写入disk 的dirty buffer ,此时对应的redo filE 状态为active表示活动的),如果都写入disk了,标记为in
active,另外如果是archive log mode那么lgWR将前一个online redofile 加入archive log列表,等待归档
4.打开redo logfile group中的所有member,记录当前日志sequence#和第一个redo block 的SCN(LOW SCN)

 

 

 

archived log:
1.archivelog mode lgwr触发arch
2.如果arch background process 5分钟后还未接到lgwr通知则发生超时,arch被唤醒检查时候存在要归档的
redo file(通过读取contorlfile来判断应该归档哪写redo),instance recovery & media recovery时 arch
processes不会启动


arch process 过程:
1.从controlfile中读取未archivelog的redofile
2.在内存中分配归档redo block,个数由(_log_archive_buffer确定),大小由(_log_archive_buffer_size确定)
3.打开online redofile group中所有日志文件,check file header
4.搜索可用archivelog dest
5.在可用archive log dest创建并打开归档日志文件
6.在redofile 取出每个redo block ,放入内存中archived log block,按SCN 顺序放入archived lof file
7.关闭所有打开的文件(online redofile & archivelog file)

 

arch process 将online redo file里的redo block读到archived log block时,如果发现所读取redo block发生损坏
则会转到相同的redo group中,另外一个日志文件(member)读取相同的redo block,整个group中所有member
这个redo block都坏了,那么arch error

arch process 在redo group中 进行循环读取(循环读取member)为了物理I/O平衡,比如读取一个redo block从
member 1 后,arch会到相同group中 读取另一个 比如member 2 读取下一个redo block


 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12020513/viewspace-617285/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/12020513/viewspace-617285/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值