7、日志切换
日志切换至后台进程LGWR停止写一个日志组,并开始写另一个日志组的事件,默认情况下,当日志组写满后,后台进程LGWR会自动进行日志切换。
当日志切换时,当前日志序列号会自动递增
也有手工切换日志
SQL> alter system switch logfile;
System altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC
---------- ---------- ---------- ---------- ---------- ---------- ---
STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------------- ------------- --------- ------------ ---------
1 1 10 52428800 512 1 YES
ACTIVE 1137238 08-JUL-12 1139309 08-JUL-12
2 1 11 52428800 512 1 NO
CURRENT 1139309 08-JUL-12 2.8147E+14
3 1 9 52428800 512 1 YES
INACTIVE 1132531 08-JUL-12 1137238 08-JUL-12
SQL> alter system switch logfile;
System altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC
---------- ---------- ---------- ---------- ---------- ---------- ---
STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------------- ------------- --------- ------------ ---------
1 1 10 52428800 512 1 YES
ACTIVE 1137238 08-JUL-12 1139309 08-JUL-12
2 1 11 52428800 512 1 YES
ACTIVE 1139309 08-JUL-12 1139367 08-JUL-12
3 1 12 52428800 512 1 NO
CURRENT 1139367 08-JUL-12 2.8147E+14
SQL> alter system archive log current;(手动归档)
System altered.
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 1139443 08-JUL-12 2.8147E+14
2 1 11 52428800 512 1 YES
ACTIVE 1139309 08-JUL-12 1139367 08-JUL-12
3 1 12 52428800 512 1 YES
ACTIVE 1139367 08-JUL-12 1139443 08-JUL-12
日志切换是,chpt发出checkpoint,然后促使scn写入控制文件和数据文件头,lgwr写完之后,dbwr开始把缓冲区脏数据写入数据文件。
当数据块处于归档模式时,日志切换时促使后台进程arch讲日志内容保存到归档日志
如下:
# pwd
/Oracle/products/diag/rdbms/wolf/wolf/alert
# ls
log.xml
# tail -f log.xml
<txt>Completed checkpoint up to RBA [0xd.2.10], SCN: 1139443
</txt>
</msg>
<msg time='2012-07-08T21:35:06.308-05:00' org_id='oracle' comp_id='rdbms'
client_id='' type='UNKNOWN' level='16'
host_id='oracle' host_addr='192.168.8.254' module=''
pid='6160592'>
<txt>Incremental checkpoint up to RBA [0xd.273.0], current log tail at RBA [0xd.2aa.0]
</txt>
</msg>
<msg time='2012-07-08T21:44:00.575-05:00' org_id='oracle' comp_id='rdbms'
client_id='' type='UNKNOWN' level='16'
host_id='oracle' host_addr='192.168.8.254' module='sqlplus@oracle (TNS V1-V3)'
pid='14680092'>
<txt>ALTER SYSTEM ARCHIVE LOG
</txt>
</msg>
<msg time='2012-07-08T21:44:00.713-05:00' org_id='oracle' comp_id='rdbms'
client_id='' type='UNKNOWN' level='16'
host_id='oracle' host_addr='192.168.8.254' module=''
pid='6357218'>
<txt>Beginning log switch checkpoint up to RBA [0xe.2.10], SCN: 1140448
</txt>
</msg>
<msg time='2012-07-08T21:44:00.713-05:00' org_id='oracle' comp_id='rdbms'
client_id='' type='UNKNOWN' level='16'
host_id='oracle' host_addr='192.168.8.254' module=''
pid='6357218'>
<txt>Thread 1 advanced to log sequence 14 (LGWR switch)
</txt>
</msg>
<msg time='2012-07-08T21:44:00.713-05:00' org_id='oracle' comp_id='rdbms'
client_id='' type='UNKNOWN' level='16'
host_id='oracle' host_addr='192.168.8.254' module=''
pid='6357218'>
<txt> Current log# 2 seq# 14 mem# 0: /oracle/products/oradata/wolf/redo02.log
</txt>
</msg>
<msg time='2012-07-08T21:44:00.890-05:00' org_id='oracle' comp_id='rdbms'
client_id='' type='UNKNOWN' level='16'
host_id='oracle' host_addr='192.168.8.254' module='sqlplus@oracle (TNS V1-V3)'
pid='14680092'>
<txt>Archived Log entry 10 added for thread 1 sequence 13 ID 0xffffffffdfbf1c80 dest 1:
</txt>
</msg>
<msg time='2012-07-08T21:49:47.708-05:00' org_id='oracle' comp_id='rdbms'
client_id='' type='UNKNOWN' level='16'
host_id='oracle' host_addr='192.168.8.254' module=''
pid='6160592'>
<txt>Completed checkpoint up to RBA [0xe.2.10], SCN: 1140448
</txt>
</msg>
<msg time='2012-07-08T22:05:15.112-05:00' org_id='oracle' comp_id='rdbms'
client_id='' type='UNKNOWN' level='16'
host_id='oracle' host_addr='192.168.8.254' module=''
pid='6160592'>
<txt>Incremental checkpoint up to RBA [0xe.295.0], current log tail at RBA [0xe.b9b.0]
</txt>
</msg>
