热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

【恢复,1】redo日志恢复的各种情况

RecoveringAftertheLossofOnlineRedoLogFilesIfamediafailurehasaffectedtheonlineredologsofadatabase,thentheappropriaterecoveryproceduredependsonthefollowingconsiderations:Theconfigurationoftheonlineredolo

Recovering After the Loss of Online Redo Log Files If a media failure has affected the online redo logs of a database, then the appropriate recovery procedure depends on the following considerations: The configuration of the online redo lo

Recovering After the Loss of Online Redo Log Files

If a media failure has affected the online redo logs of a database, then the appropriate recovery procedure depends on the following considerations:

    The configuration of the online redo log: mirrored or non-mirrored

    The type of media failure: temporary or permanent

    The types of online redo log files affected by the media failure: current, active, unarchived, or inactive

    Table 30-3 displays V$LOG status information that can be crucial in a recovery situation involving online redo logs.

    Table 30-3 STATUS Column of V$LOG

    Status Description

    UNUSED

    The online redo log has never been written to.

    CURRENT

    The online redo log is active, that is, needed for instance recovery, and it is the log to which the database is currently writing. The redo log can be open or closed.

    ACTIVE

    The online redo log is active, that is, needed for instance recovery, but is not the log to which the database is currently writing. It may be in use for block recovery, and may or may not be archived.

    CLEARING

    The log is being re-created as an empty log after an ALTER DATABASE CLEAR LOGFILE statement. After the log is cleared, then the status changes to UNUSED.

    CLEARING_CURRENT

    The current log is being cleared of a closed thread. The log can stay in this status if there is some failure in the switch such as an I/O error writing the new log header.

    INACTIVE

    The log is no longer needed for instance recovery. It may be in use for media recovery, and may or may not be archived.


    Recovering After Losing a Member of a Multiplexed Online Redo Log Group

    You can recover after losing a member of a multiplexed online redo log group. The database continues to function as usual during the following conditions:

    If the online redo log of a database is multiplexed, and if at least one member of each online redo log group is not affected by the media failure, then the database continues functioning as usual, but error messages are written to the log writer trace file and the alert_SID.log of the database.

    You can resolve the problem of a missing member of a multiplexed online redo log group by taking one of the following actions:

    If the hardware problem is temporary, then correct it. The log writer process accesses the previously unavailable online redo log files as if the problem never existed.

    If the hardware problem is permanent, then drop the damaged member and add a new member by using the following procedure.

    Note:

    The newly added member provides no redundancy until the log group is reused.

    Locate the file name of the damaged member in V$LOGFILE. The status is INVALID if the file is inaccessible:

    SELECT GROUP#, STATUS, MEMBER 
    FROM V$LOGFILE
    WHERE STATUS='INVALID';
    
    GROUP#    STATUS       MEMBER
    -------   -----------  ---------------------
    0002      INVALID      /disk1/oradata/trgt/redo02.log
    

    Drop the damaged member. For example, to drop member redo02.log from group 2, issue the following statement:

    ALTER DATABASE DROP LOGFILE MEMBER '/disk1/oradata/trgt/redo02.log';
    

    Add a new member to the group. For example, to add redo02.log to group 2, issue the following statement:

    ALTER DATABASE ADD LOGFILE MEMBER '/disk1/oradata/trgt/redo02b.log' 
      TO GROUP 2;
    

    If the file that you want to add exists, then it must be the same size as the other group members, and you must specify the REUSE option. For example:

    ALTER DATABASE ADD LOGFILE MEMBER '/disk1/oradata/trgt/redo02b.log'
      REUSE TO GROUP 2;

    Recovering After Losing All Members of an Online Redo Log Group

    丢失online redo 日志组所有成员后恢复

    If a media failure damages all members of an online redo log group, then different scenarios can occur depending on the type of online redo log group affected by the failure and the archiving mode of the database.

    如果介质故障损坏所有的日志组的成员,不同场景下发生的失败影响依赖于日志组类型和数据库的归档模式。

    If the damaged online redo log group is current and active, then it is needed for crash recovery; otherwise, it is not. Table 30-4 outlines the various recovery scenarios.

    如果损坏的当前日志组时current和active,那么需要做故障恢复。

    Table 30-4 Recovering After the Loss of an Online Redo Log Group

    If the Group Is... Then... And You Should...

    Inactive

    It is not needed for crash recovery

    Clear the archived or unarchived group.

    Active

    It is needed for crash recovery

    Attempt to issue a checkpoint and clear the log; if impossible, then you must either use Flashback Database or restore a backup and perform incomplete recovery up to the most recent available redo log.

    试着执行checkpoint和clear日志,如果不能,那么你必须要么使用闪回数据库要么使用转储备份 执行不完全恢复到最近可用的redo log。

    Current

    It is the redo log that the database is currently writing to

    Attempt to clear the log; if impossible, then you must either use Flashback Database or restore a backup and perform incomplete recovery up to the most recent available redo log.


    To determine whether the damaged group is active or inactive.

    确定损坏的组是否是acitve 或inactive

      Locate the file name of the lost redo log in V$LOGFILE and then look for the group number corresponding to it. For example, enter:

      SELECT GROUP#, STATUS, MEMBER FROM V$LOGFILE;
      
      GROUP#    STATUS       MEMBER
      -------   -----------  ---------------------
      0001                    /oracle/dbs/log1a.f
      0001                    /oracle/dbs/log1b.f
      0002      INVALID       /oracle/dbs/log2a.f
      0002      INVALID       /oracle/dbs/log2b.f
      0003                    /oracle/dbs/log3a.f
      0003                    /oracle/dbs/log3b.f
      

      Determine which groups are active.

      For example, execute the following SQL query (sample output included):

      SELECT GROUP#, MEMBERS, STATUS, ARCHIVED 
      FROM V$LOG;
      
      GROUP#  MEMBERS           STATUS     ARCHIVED
      ------  -------           ---------  -----------
       0001   2                 INACTIVE   YES
       0002   2                 ACTIVE     NO
       0003   2                 CURRENT    NO
      

      Perform one of the following actions:

      If the affected group is inactive, then follow the procedure in "Losing an Inactive Online Redo Log Group".

      If the affected group is active (as in the preceding example), then follow the procedure in "Losing an Active Online Redo Log Group".



      Losing an Inactive Online Redo Log Group

      丢失inactive 日志组

      If all members of an online redo log group with INACTIVE status are damaged, then the procedure depends on whether you can fix the media problem that damaged the inactive redo log group. If the failure is temporary, then fix the problem. The log writer can reuse the redo log group when required. If the failure is permanent, then the damaged inactive online redo log group eventually halts normal database operation. Reinitialize the damaged group manually by issuing the ALTER DATABASE CLEAR LOGFILE statement as described in this section.

      inactive状态的日志组所有成员损坏。那么程序依赖于你能否定位inactive日志组的介质问题(日志文件是否损坏),如果介质故障是临时的,log writer 能重新使用 日志组。如果介质故障是永久的,那么损坏的inactive日志组最终会停止正常的数据库操作。通过执行alter database CLEAR LOGFILE语句手动的重新初始化损坏的日志组。

      Clearing Inactive, Archived Redo

      清除inactive 已归档的日志

      You can clear an inactive redo log group when the database is open or closed. The procedure depends on whether the damaged group has been archived.

      数据库开启或关闭都能 clear inactive 日志组。依赖于损坏的日志组是否归档。

      To clear an inactive, online redo log group that has been archived:

      If the database is shut down, then start a new instance and mount the database:

      STARTUP MOUNT
      

      Reinitialize the damaged log group. For example, to clear redo log group 2, issue the following statement:

      ALTER DATABASE CLEAR LOGFILE GROUP 2;
      
      Clearing Inactive, Unarchived Redo

      清除 inactive 未归档的日志

      Clearing a not-yet-archived redo log allows it to be reused without archiving it. This action makes backups unusable if they were started before the last change in the log, unless the file was taken offline before the first change in the log. Hence, if you need the cleared log file for recovery of a backup, then you cannot recover that backup. Clearing a not-yet-archived-redo-log, prevents complete recovery from backups due to the missing log.

      清除的没有归档的日志允许被被重用。如果日志的最后一次改变之前开始, 这个操作会导致备份不可用,除非日志文件在第一次改变之前被置为offline。此后,如果你需要被清除的日志去做备份恢复,是不能备份恢复的。

      To clear an inactive, online redo log group that has not been archived:

      清除一个inactive ,日志没有归档:

      If the database is shut down, then start a new instance and mount the database:

      SQL> STARTUP MOUNT
      

      Clear the log using the UNARCHIVED keyword.

      For example, to clear log group 2, issue the following SQL statement:

      SQL> ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 2;
      

      If there is an offline data file that requires the cleared log to bring it online, then the keywords UNRECOVERABLE DATAFILE are required. The data file must be dropped because the redo logs necessary to bring the data file online are being cleared, and there is no copy of it. For example, enter:

      如果有一个数据文件offline, 需要清除日志后使数据文件上线,那么此时需要使用关键字UNRECOVERABLE DATAFILE.数据文件必须被删除因为

      SQL> ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 2 UNRECOVERABLE DATAFILE;
      

      Immediately back up all data files in the database with an operating system utility, so that you have a backup you can use for complete recovery without relying on the cleared log group. For example, enter:

      立即备份所有的数据文件使用操作系统工具,以至于你有一个不用依赖被清除的日志组就能做完全恢复的备份,

      % cp /disk1/oracle/dbs/*.dbf /disk2/backup
      

      Back up the database's control file with the ALTER DATABASE statement. For example, enter:

      SQL> ALTER DATABASE BACKUP CONTROLFILE TO '/oracle/dbs/cf_backup.f';
      
      Failure of CLEAR LOGFILE Operation
      失败的清除日志文件操作

      The ALTER DATABASE CLEAR LOGFILE statement can fail with an I/O error due to media failure when it is not possible to:

      alter database clear logfile 语句如果不能做下面的操作 会失败由于介质故障导致的io错误,

        Relocate the redo log file onto alternative media by re-creating it under the currently configured redo log file name

        通过当前配置的日志文件的名称重新创建日志文件 迁移日志日志到另外的介质上

        Reuse the currently configured log file name to re-create the redo log file because the name itself is invalid or unusable (for example, due to media failure)

        重新使用当前的配置日志文件的名称去重新创建日志文件因为他自己的名字是无效的或者不可用。

        In these cases, the ALTER DATABASE CLEAR LOGFILE statement (before receiving the I/O error) would have successfully informed the control file that the log was being cleared and did not require archiving. The I/O error occurred at the step in which the CLEAR LOGFILE statement attempted to create the new redo log file and write zeros to it. This fact is reflected in V$LOG.CLEARING_CURRENT.

        在这些情况下,alter database clear logfile 语句

        Losing an Active Online Redo Log Group

        If the database is still running and the lost active redo log is not the current log, then issue the ALTER SYSTEM CHECKPOINT statement. If the operation is successful, then the active redo log becomes inactive, and you can follow the procedure in "Losing an Inactive Online Redo Log Group". If the operation is unsuccessful, or if your database has halted, then perform one of procedures in this section, depending on the archiving mode.

        The current log is the one LGWR is currently writing to. If a LGWR I/O operation fails, then LGWR terminates and the instance fails. In this case, you must restore a backup, perform incomplete recovery, and open the database with the RESETLOGS option.

        Recovering from the Loss of Active Logs in NOARCHIVELOG Mode

        In this scenario, the database archiving mode is NOARCHIVELOG.

        To recover from the loss of an active online log group in NOARCHIVELOG mode:

        If the media failure is temporary, then correct the problem so that the database can reuse the group when required.

        Restore the database from a consistent, whole database backup (data files and control files). For example, enter:

        % cp /disk2/backup/*.dbf $ORACLE_HOME/oradata/trgt/
        

        Mount the database:

        STARTUP MOUNT
        

        Because online redo logs are not backed up, you cannot restore them with the data files and control files. To allow the database to reset the online redo logs, you must first mimic incomplete recovery:

        RECOVER DATABASE UNTIL CANCEL
        CANCEL
        

        Open the database using the RESETLOGS option:

        ALTER DATABASE OPEN RESETLOGS;
        

        Shut down the database consistently. For example, enter:

        SHUTDOWN IMMEDIATE
        

        Make a whole database backup.

        If the media failure is temporary, then correct the problem so that the database can reuse the group when required. If the media failure is not temporary, then use the following procedure.

        Recovering from Loss of Active Logs in ARCHIVELOG Mode

        In this scenario, the database archiving mode is ARCHIVELOG.

        To recover from loss of an active online redo log group in ARCHIVELOG mode:

        Begin incomplete media recovery, recovering up through the log before the damaged log.

        Ensure that the current name of the lost redo log can be used for a newly created file. If not, then rename the members of the damaged online redo log group to a new location. For example, enter:

        ALTER DATABASE RENAME FILE "/disk1/oradata/trgt/redo01.log" TO "/tmp/redo01.log";
        ALTER DATABASE RENAME FILE "/disk1/oradata/trgt/redo02.log" TO "/tmp/redo02.log";
        

        Open the database using the RESETLOGS option:

        ALTER DATABASE OPEN RESETLOGS;
        

        Note:

        All updates executed from the end point of the incomplete recovery to the present must be re-executed.

        Loss of Multiple Redo Log Groups

        If you have lost multiple groups of the online redo log, then use the recovery method for the most difficult log to recover. The order of difficulty, from most difficult to least difficult, is as follows:

        The current online redo log

        An active online redo log

        An unarchived online redo log

        An inactive online redo log


        来源: >




推荐阅读
  • PHP 5.2.5 安装与配置指南
    本文详细介绍了 PHP 5.2.5 的安装和配置步骤,帮助开发者解决常见的环境配置问题,特别是上传图片时遇到的错误。通过本教程,您可以顺利搭建并优化 PHP 运行环境。 ... [详细]
  • 构建基于BERT的中文NL2SQL模型:一个简明的基准
    本文探讨了将自然语言转换为SQL语句(NL2SQL)的任务,这是人工智能领域中一项非常实用的研究方向。文章介绍了笔者在公司举办的首届中文NL2SQL挑战赛中的实践,该比赛提供了金融和通用领域的表格数据,并标注了对应的自然语言与SQL语句对,旨在训练准确的NL2SQL模型。 ... [详细]
  • Hadoop入门与核心组件详解
    本文详细介绍了Hadoop的基础知识及其核心组件,包括HDFS、MapReduce和YARN。通过本文,读者可以全面了解Hadoop的生态系统及应用场景。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • 深入理解 SQL 视图、存储过程与事务
    本文详细介绍了SQL中的视图、存储过程和事务的概念及应用。视图为用户提供了一种灵活的数据查询方式,存储过程则封装了复杂的SQL逻辑,而事务确保了数据库操作的完整性和一致性。 ... [详细]
  • 本文详细介绍了HTML中标签的使用方法和作用。通过具体示例,解释了如何利用标签为网页中的缩写和简称提供完整解释,并探讨了其在提高可读性和搜索引擎优化方面的优势。 ... [详细]
  • 数据库内核开发入门 | 搭建研发环境的初步指南
    本课程将带你从零开始,逐步掌握数据库内核开发的基础知识和实践技能,重点介绍如何搭建OceanBase的开发环境。 ... [详细]
  • 本文深入探讨 MyBatis 中动态 SQL 的使用方法,包括 if/where、trim 自定义字符串截取规则、choose 分支选择、封装查询和修改条件的 where/set 标签、批量处理的 foreach 标签以及内置参数和 bind 的用法。 ... [详细]
  • DNN Community 和 Professional 版本的主要差异
    本文详细解析了 DotNetNuke (DNN) 的两种主要版本:Community 和 Professional。通过对比两者的功能和附加组件,帮助用户选择最适合其需求的版本。 ... [详细]
  • 本文探讨了 C++ 中普通数组和标准库类型 vector 的初始化方法。普通数组具有固定长度,而 vector 是一种可扩展的容器,允许动态调整大小。文章详细介绍了不同初始化方式及其应用场景,并提供了代码示例以加深理解。 ... [详细]
  • 网络运维工程师负责确保企业IT基础设施的稳定运行,保障业务连续性和数据安全。他们需要具备多种技能,包括搭建和维护网络环境、监控系统性能、处理突发事件等。本文将探讨网络运维工程师的职业前景及其平均薪酬水平。 ... [详细]
  • 高效解决应用崩溃问题!友盟新版错误分析工具全面升级
    友盟推出的最新版错误分析工具,专为移动开发者设计,提供强大的Crash收集与分析功能。该工具能够实时监控App运行状态,快速发现并修复错误,显著提升应用的稳定性和用户体验。 ... [详细]
  • 本题涉及一棵由N个节点组成的树(共有N-1条边),初始时所有节点均为白色。题目要求处理两种操作:一是改变某个节点的颜色(从白变黑或从黑变白);二是查询从根节点到指定节点路径上的第一个黑色节点,若无则输出-1。 ... [详细]
  • 并发编程:深入理解设计原理与优化
    本文探讨了并发编程中的关键设计原则,特别是Java内存模型(JMM)的happens-before规则及其对多线程编程的影响。文章详细介绍了DCL双重检查锁定模式的问题及解决方案,并总结了不同处理器和内存模型之间的关系,旨在为程序员提供更深入的理解和最佳实践。 ... [详细]
  • 技术人员转型项目管理:常见思维误区与挑战解析
    本文探讨了技术人员在向项目管理角色转变过程中常见的思维误区和困惑,分析了如何有效管理项目中的事务和人员,提供了实用的解决方案。 ... [详细]
author-avatar
优雅de禽兽
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有