欢迎您的到来!本空间用来记录日常工作心得和一些小经验.内容可能部分摘自您的辛苦创作,再次对您表示感谢.希望本空间能给您或者其他朋友一些帮助. PS:寻求福州ORACLE DBA工作,期待您的惠顾(kugooo@live.cn)

alter system switch logfile 和 alter system archive log current 的区别

上一篇 / 下一篇  2008-07-09 18:15:02 / 个人分类:ORACLE--备份恢复

主要区别:

ALTER SYSTEM SWITCH LOGFILE 对单实例数据库或RAC中的当前实例执行日志切换。
Y!{q8r%U-qDo0ALTER SYSTEM ARCHIVE LOG CURRENT 会对数据库中的所有实例执行日志切换。

ITPUB个人空间Dmt0W)e,k q

详细解释:

-------------------------

我们都知道在自动归档的数据库中,这两个命令几乎产生的结果是一样的。来看看oracle的解释:

ALTER SYSTEM SWITCH LOGFILE ;
X)S([A5I\7t\XW0
SWITCH LOGFILE ClauseITPUB个人空间;d_pD'`
The SWITCH LOGFILE clause lets you explicitly force Oracle to begin writing to a new redo log file group, regardless of whether the files in the current redo log file group are full. When you force a log switch, Oracle begins to perform. a checkpoint but returns control to you immediately rather than when the checkpoint is complete. To use this clause, your instance must have the database open.
ALTER SYSTEM ARCHIVE LOG CURRENT ;ITPUB个人空间#N_j5?;qQS
CURRENT ClauseITPUB个人空间I:M,n3{h8C
Specify CURRENT to manually archive the current redo log file group of the specified thread, forcing a log switch. If you omit the THREAD parameter, then Oracle archives all redo log file groups from all enabled threads, including logs previous to current logs. You can specify CURRENT only when the database is open.
ALTER SYSTEM ARCHIVE LOG CURRENT NOSWITCH;
Qx4BL(pn2P4X Z+wh0NOSWITCHITPUB个人空间ebS-k!s-`1| QED
Specify NOSWITCH if you want to manually archive the current redo log file group without forcing a log switch. This setting is used primarily with standby databases to prevent data divergence when the primary database shuts down. Divergence implies the possibility of data loss in case of primary database failure.
You can use the NOSWITCH clause only when your instance has the database mounted but not open. If the database is open, then this operation closes the database automatically. You must then manually shut down the database before you can reopen it
ITPUB个人空间} S \TS%}
我们首先要明白两个事实:ITPUB个人空间q;?d@%_k*JD
一个就是在logfile switch的时候会触发arch进程,即通知归档进程说那个日志可以归档了。ITPUB个人空间U|2t+R Z_,w
另一个是logfile switch的时候会触发ckpt进程。而ckpt进程又会触发dbwr进程。dbwr进程会把上一个redo中保护的储藏在buffer cache中的dirty buffer全部写回磁盘。然后,ckpt进程纪录scn到controlfile中,这时会把redo log的状态由active 变成inactive。
由此我们可以看出处于inactive状态的redo log对于instance recovery是没有用处了。但是它可能对于meda recovery还有用处,因为处于inactive状态的redo log可能已经归档,也可能没有归档。
出现 checkpoint not complete,unable to allocate new redo log file的错误,是因为lgwr要覆盖一个其上检查点过程没有结束的日志文件,lgwr会等待dbwr完成,同时出现此错误。出现这个错误的原因,大概有几点,一个是dbwr写出速度太慢,一个是buffer cache中的脏数据太多。即事务太频繁,另一个也可能是日志太小,或日志组太少导致的。

备份恢复中用到的几个操作:

alter system checkpoint;
[u'yy/H3bs0alter system archive log all;
aw+y#s)i3[,[ V0alter system archive log currentITPUB个人空间Q\sDW
alter system switch logfile;

1:alter system checkpoint;

Specify CHECKPOINT to explicitly force Oracle to perform. a checkpoint, ensuring that all changes made by committed transactions are written to datafiles on disk. You can specify this clause only when your instance has the database open. Oracle does not return control to you until the checkpoint is complete.ITPUB个人空间z#hdr*{;B
强迫oracle进行以次检查点,确保所有提交的事务的改变都被写到磁盘数据文件上。

2: alter system archive log all;

手工归档所有的日志文件组

3:alter system archive log current

手工归档活动的日志文件组。
6E,~ {_N-F04: alter system switch logfile;
3R"I$Y!O5iE0The SWITCH LOGFILE clause lets you explicitly force Oracle to begin writing to a new redo log file group, regardless of whether the files in the current redo log file group are full. When you force a log switch, Oracle begins to perform. a checkpoint but returns control to you immediately rather than when the checkpoint is complete. To use this clause, your instance must have the database open.ITPUB个人空间0j/SAA3A
开始写新的日志文件组。不管当前日志文件组是否满了。


TAG: logfile switch

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-09-07  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 623
  • 日志数: 17
  • 文件数: 1
  • 建立时间: 2007-12-25
  • 更新时间: 2008-09-03

RSS订阅

Open Toolbar