免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1625 | 回复: 0
打印 上一主题 下一主题

[Hive] alter system switch logfile 和 alter system archive [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-21 08:44 |只看该作者 |倒序浏览
<p><font size="2" face="Verdana">主要区别:</font></p><p><font size="2" face="Verdana">ALTER SYSTEM <a target="_self"><u><strong>SWITCH</strong></u></a> <a target="_self"><u><strong>LOGFILE</strong></u></a> 对单实例<a target="_self"><u><strong>数据库</strong></u></a>或RAC中的当前实例执行日志切换。<br>ALTER SYSTEM ARCHIVE LOG CURRENT 会对数据库中的所有实例执行日志切换。</font></p><br><p><font size="2" face="Verdana">详细解释:</font></p><p><font size="2" face="Verdana">-------------------------</font></p><p><font size="2" face="Verdana">我们都知道在自动归档的数据库中,这两个命令几乎产生的结果是一样的。来看看<a target="_self"><u><strong>oracle</strong></u></a>的解释:</font></p><div><font size="2" face="Verdana"><font style="BACKGROUND-COLOR: #a6a6a6" color="#660000">ALTER SYSTEM SWITCH LOGFILE ;<br></font>SWITCH LOGFILE Clause<br>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 <a target="_self"><u><strong>database</strong></u></a> open.</font></div><div><font size="2" face="Verdana">ALTER SYSTEM ARCHIVE LOG CURRENT ;<br>CURRENT Clause<br>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.</font></div><div><font size="2" face="Verdana"><font style="BACKGROUND-COLOR: #a6a6a6" color="#660000">ALTER SYSTEM ARCHIVE LOG CURRENT NOSWITCH;</font><br>NOSWITCH<br>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.</font></div><div><font size="2" face="Verdana">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</font></div><div><br><font size="2" face="Verdana">我们首先要明白两个事实:<br>一个就是在logfile switch的时候会触发arch进程,即通知归档进程说那个日志可以归档了。<br>另
一个是logfile
switch的时候会触发ckpt进程。而ckpt进程又会触发dbwr进程。dbwr进程会把上一个redo中保护的储藏在buffer
cache中的dirty buffer全部写回磁盘。然后,ckpt进程纪录scn到controlfile中,这时会把redo
log的状态由active 变成inactive。</font></div><div><font size="2" face="Verdana">由此我们可以看出处于inactive状态的redo log对于instance recovery是没有用处了。但是它可能对于meda recovery还有用处,因为处于inactive状态的redo log可能已经归档,也可能没有归档。</font></div><div><font size="2" face="Verdana">出现 checkpoint not complete,unable to allocate new redo log file的错误,是因为lgwr要覆盖一个其上检查点过程没有结束的日志文件,lgwr会<a class="qs_highlight1" id="hl_0" style="FONT-SIZE: 1em" href="http://clk.qunsee.com/click/click.php?cpid=12&amp;ads_id=77&amp;pid=99002480&amp;cid=2487&amp;url=http%3A//otr.samsung.com.cn/&amp;k=%u7B49%u5F85&amp;s=http%3A//www.ixdba.net/article/88/1260.html&amp;rn=861797&amp;v=1&amp;ref=http%3A//www.google.cn/search%3Fcomplete%3D1%26hl%3Dzh-CN%26newwindow%3D1%26q%3Dlog+file+switch%26revid%3D2081610865%26sa%3DX%26oi%3Drevisions_inline%26resnum%3D0%26ct%3Dbroad-revision%26cd%3D4&amp;province=%u798F%u5EFA&amp;city=%u798F%u5DDE" target="_blank">等待</a>dbwr完成,同时出现此错误。出现这个错误的原因,大概有几点,一个是dbwr写出速度太慢,一个是buffer cache中的脏数据太多。即事务太频繁,另一个也可能是日志太小,或日志组太少导致的。</font></div><div><p><font size="2" face="Verdana"><strong><a target="_self"><u><strong>备份</strong></u></a>恢复中用到的几个操作:</strong></font></p><p><font size="2" face="Verdana">alter system checkpoint;<br>alter system archive log all;<br>alter system archive log current<br>alter system switch logfile;</font></p><p><font size="2" face="Verdana">1:alter system checkpoint;</font></p><p><font size="2" face="Verdana">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.<font size="2" face="Verdana"><a href="http://www.ixdba.net/"><font color="#ecf4f5" size="2" face="Verdana"><strong>区</strong></font></a></font><br>强迫oracle进行以次检查点,确保所有提交的事务的改变都被写到磁盘数据文件上。</font></p><p><font size="2">2: alter system archive log all;</font></p><p><font size="2" face="Verdana">手工归档所有的日志文件组</font></p><p><font size="2" face="Verdana">3:alter system archive log current</font></p><p><font size="2" face="Verdana">手工归档<a class="qs_highlight1" id="hl_1" style="FONT-SIZE: 1em" href="http://clk.qunsee.com/click/click.php?cpid=1021&amp;ads_id=941&amp;pid=99002480&amp;cid=2487&amp;url=http%3A//www.chanet.com.cn/click.cgi%3Fa%3D59068%26d%3D36229%26u%3D%26e%3D&amp;k=%u6D3B%u52A8&amp;s=http%3A//www.ixdba.net/article/88/1260%242.html&amp;rn=998285&amp;v=1&amp;ref=http%3A//www.ixdba.net/article/88/1260.html&amp;province=%u798F%u5EFA&amp;city=%u798F%u5DDE" target="_blank">活动</a>的日志文件组。<br>4: alter system switch logfile;<br>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.<br>开始写新的日志文件组。不管当前日志文件组是否满了。</font></p></div>
               
               
               
               
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP