alter database clear logfile group
或者
alter database clear unarchived logfile group应该是会清空日志中的东西,那如果在数据库恢复的时候,会不会导致数据丢失?

解决方案 »

  1.   

    这个两种不同的情况,一般情况下,当redo 损坏时,会执行这两条命令。 对于已经完成归档的redo group,即状态为inactive的redo group:
    执行: alter database clear logfile group 
    因为这种情况下,redo 已经完成归档,所以恢复时不会造成数据的丢失。当redo 为active时,即表示正在归档,这个时候,只能执行:
    alter database clear unarchived logfile group这个时候,如果进行恢复,是会有数据丢失的。 一般除非redo 损坏才会用到这个命令。具体的情况还是需要具体对待。 如果的Data Guard 环境,执行了alter database clear unarchived logfile group,那么DG 就需要重新搭建了。参考:
    Oracle 不同故障的恢复方案
    http://blog.csdn.net/tianlesoftware/archive/2010/12/30/6106178.aspx
      

  2.   

    还有个 问题  alter system switch logfile; 网络上说 这步是  执行切换,不一定能归档。 alter system archive log current;我就晕了 , 每次执行alter system switch logfile ,都会重新生成归档日志 ,怎么还不算是归档。。
      

  3.   

    tianlesoftware,好详细,赞一个
    alter system switch logfile 会不会马上产生归档日志,得看系统数据库繁忙程度,有时日志应用不及时就不能马上归档,当然这些都必须在开启归档状态下进行。
      

  4.   

    it would be normal for a redo log file to be
                                                                                    
    active -- has stuff in it that is needed for instance recovery if we crashed
    right now.
                                                                                    
    current -- where stuff is being written to right now
                                                                                    
    inactive -- was used at some point, but isn't needed for instance recovery
    anymore (all blocks it was protecting have been flushed to disk by a
    checkpoint) and isn't the current redo log file...
                                                                                    
                                                                                    
                                                                                    
    All other status would be "not normal" and after some period of activity
    would become "normal"
      

  5.   

    ops$tkyte@ORA9IR2> alter system switch logfile;
     
    System altered.
     
    ops$tkyte@ORA9IR2> alter database clear logfile group 1;
    alter database clear logfile group 1
    *
    ERROR at line 1:
    ORA-01624: log 1 needed for crash recovery of thread 1
    ORA-00312: online log 1 thread 1: '/home/ora9ir2/oradata/ora9ir2/redo01.log'
     
    now we cannot clear it because of dirty blocks in the cache, so we get rid of them
     
    ops$tkyte@ORA9IR2> alter system checkpoint
      2  /
     
    System altered.
     
    ops$tkyte@ORA9IR2> alter database clear logfile group 1;
     
    Database altered.