Crash Recovery 和 Media Recovery 的区别

本文介绍了Oracle数据库中的两种恢复机制:实例崩溃恢复与介质恢复。前者在实例崩溃后自动进行,确保数据文件达到一致状态;后者则需手动启动,用于恢复损坏的数据文件。两者在使用日志、触发条件等方面存在差异。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 一直自以为挺明白的 看了文档后 这次才清清楚楚 最重要的文档一直就是概念和原理..

 

Backup and Recovery Basis

1.4.3 Automatic Recovery After Instance Failure: Crash Recovery

The crash recovery process is a special form of recovery, which happens the first time an Oracle database instance is started after a crash (or SHUTDOWN ABORT). In crash recovery, the goal is to bring the datafiles to a transaction-consistent state, preserving all committed changes up to the point when the instance failed.

Like crash recovery, datafile media recovery is intended to restore database integrity. However, there are a number of important differences between the two:

  • Media recovery must be explicitly invoked by a user. The database will not run media recovery on its own.

  • Media recovery applies needed changes to datafiles that have been restored from backup, not to online datafiles left over after a crash.

  • Media recovery must use archived logs as well as the online logs, to find changes reaching back to the time of the datafile backup.

Unlike the forms of recovery performed manually after a data loss, crash recovery uses only the online redo log files and current online datafiles, as left on disk after the instance failure. Archived logs are never used during crash recovery, and datafiles are never restored from backup.

The database applies any pending updates in the online redo logs to the online datafiles of your database. The result is that, whenever the database is restarted after a crash, the datafiles reflect all committed changes up to the moment when the haven't said failure occurred. (After the database opens, any changes that were part of uncommitted transactions at the time of the crash are rolled back.)

The duration of crash recovery is a function of the number of instances needing recovery, amount of redo generated in the redo threads of crashed instances since the last checkpoint, and user-configurable factors such as the number and size of redo log files, checkpoint frequency, and the parallel recovery setting.You can set parameters in the database server that can tune the duration of crash recovery. You can also tune checkpointing to optimize recovery time.

DB2的crash recovery是指在数据库系统发生故障导致系统崩溃时,通过一定的恢复机制来恢复数据库系统的过程。下面是对DB2 crash recovery的分析: 1. Crash recovery的原理 DB2的crash recovery是基于日志记录回放的原理实现的。当DB2发生故障时,系统会将当前的数据库状态记录到日志文件中。在系统恢复时,DB2会分析日志文件中记录的操作,重新执行这些操作,以恢复数据库到故障前的状态。 2. Crash recovery的流程 DB2的crash recovery流程大致分为以下几个步骤: (1)确定crash recovery的起点:DB2系统会检查日志文件,以确定crash recovery的起点。通常情况下,起点是最后一个提交的事务。 (2)执行redo操作:DB2系统会执行redo操作,即重放所有未提交的操作,以使数据库恢复到crash recovery起点之前的状态。 (3)执行undo操作:DB2系统会执行undo操作,即回滚所有已提交的操作,以消除因为crash recovery而造成的数据不一致问题。 (4)更新数据结构:DB2系统会更新数据结构,以反映数据库的最新状态。 (5)完成crash recovery:当DB2系统执行完以上步骤后,crash recovery就完成了。此时,数据库已经恢复到了故障前的状态。 3. Crash recovery的优化 为了加速crash recovery的速度,DB2提供了一些优化技术。例如,DB2可以通过使用多线程来并行执行redoundo操作,以加快恢复速度。此外,DB2还可以通过启用log buffer来减少日志写入到磁盘的次数,从而提高性能。 总之,DB2的crash recovery是一个重要的恢复机制,它可以保证数据库在发生故障时能够及时恢复到正常状态。了解crash recovery的原理流程,对于DB2的管理维护是非常重要的。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值