Home Database Mysql Tutorial Oracle恢复内部原理(介质恢复)

Oracle恢复内部原理(介质恢复)

Jun 07, 2016 pm 05:27 PM
o oracle recovery

介质恢复用在丢失或损坏数据文件或者丢失了控制文件的情形。介质恢复将还原的数据文件恢复成当前数据文件。还能够恢复数据文件异

介质恢复用在丢失或损坏数据文件或者丢失了控制文件的情形。介质恢复将还原的数据文件恢复成当前数据文件。还能够恢复数据文件异常脱机时没有来得及做检查点操作丢失的变更。介质恢复使用归档日志和联机日志。跟实例恢复不同的是,介质恢复必须由命令显式调用。

系列文章:Oracle恢复内部原理 ?where=nkey&keyword=19824

6.1  什么时候做介质恢复

由5.3节知道,,数据文件如果是还原的备份,在打开前都要进行介质恢复,即使是应用联机日志就可以恢复的。另外一种情形就是数据文件异常脱机没有做检查点操作。不做介质恢复数据库是无法打开的,需要介质恢复的数据文件也不能联机。数据库没有被任何实例打开的时候,介质恢复只能在脱机的数据文件上恢复。即使有崩溃恢复的时候也要在打开数据库显示调用介质恢复命令。此时崩溃恢复可能没有什么做的但还是会自动运行。有时候介质恢复可能发现没有日志要应用,就会报错“不需要介质恢复”,即该文件不需要恢复。

如果当前控制文件丢失了,将一个备份控制文件还原了,介质恢复就必须做了,这是所有数据文件都联机的时候还要介质恢复的一个例子。

6.2  线程合并重做程序

介质恢复应用重做日志时用的是线程合并的重做算法。即它要同时应用所有线程的重做日志,按SCN递增的顺序合并重做日志。在还原的数据文件上应用介质恢复的过程跟在联机数据文件上应用崩溃恢复的过程的不同在于:崩溃恢复同一时刻只会应用来自一个线程的日志,因为同一时刻数据文件上的块只需要最多一个线程的重做日志(同一时刻只有一个实例可能修改该块)。在还原的备份上,则无法猜测跟该块有关的线程数目。通常介质恢复时需要同时读取所有线程的重做日志,然后按照SCN递增的顺序合并重做日志。注意这个算法依赖于数据块的变更各个线程都是按SCN递增的顺序记录的(并行服务器环境中)。

6.3  还原备份

在数据库关闭或者数据文件脱机的情况下,可以将该数据文件的备份还原。注意绝不能在数据文件还在使用的情况下还原。每次都数据文件头时都会校验数据文件头部的检查点计数和数据文件在控制文件中的检查点计数以检测是否发生这种非法操作。

6.4  介质恢复命令

介质恢复命令有三种:

RECOVER DATABASE

RECOVER TABLESPACE

RECOVER DATAFILE

这三个命令的根本区别在于恢复的数据文件集合不同。三个命令都用同样的标准决定每个数据文件是否要做介质恢复。每个数据文件上都一个排它锁,介质恢复程序开始恢复前会先申请获得这个锁。如果得不到就触发一个错误。这可以防止两个恢复会话同时恢复同一个数据文件以及防止对一个在使用的数据文件进行介质恢复。

6.4.1  RECOVER DATABASE

这个命令用来恢复所有联机数据文件。如果所有实例都正常关闭并且也没有数据文件被还原,这个命令会触发一个“no recovery required”的错误。当有实例已经打开了数据文件时这个命令也会报错因为该实例已经持有所有的锁。

6.4.2  RECOVER TABLESPACE

这个命令用来恢复指定表空间上的所有数据文件。为了将表空间名转换成具体的数据文件名,数据库必须先打开。这意味着这个表空间及其所有数据文件在数据库打开前得先脱机才能进行介质恢复。如果该表空间的所有数据文件都不需要介质恢复时会触发一个错误说没有文件需要介质恢复。

6.4.3  RECOVER DATAFILE

这个命令用来恢复指定的数据文件,无论数据库是否打开,只要能获得该数据文件上的介质恢复锁即可。当一个实例已经打开数据库的时候,则只能在脱机的数据文件上做介质恢复。

6.5  开始介质恢复

介质恢复时开始查找介质恢复起始SCN。如所有要恢复的数据文件的文件头中最低的检查点SCN。注意:如果一个数据文件的检查点SCN落在它的脱机SCN 范围内(见2.18)则会引发一个异常。此时,该数据文件的脱机结束SCN将替代文件头检查点SCN参与计算介质恢复起始SCN。

然后每个启用的线程(指在介质恢复开始SCN那一刻处于启用状态的线程,见2.10)都会分配一个缓冲区用来读取重做日志。每个文件的文件头的检查点 SCN被保存下来用来确保在这个SCN以前的重做日志不需要应用。结束SCN(控制文件中记录的)也被保存下来。如果是无穷大则取最大的结束SCN用来告诉介质恢复在何处停止,超出这个SCN的重做日志不需要应用(见6.10)。介质恢复结束时,之前结束SCN为无穷大的数据文件会在该结束SCN处做一个检查点操作(而不是在介质恢复结束点)。这使得一个干净脱机或者只读的数据文件在跟它的表空间干净结束SCN处进行检查点操作。

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Digital audio output interface on the motherboard-SPDIF OUT Digital audio output interface on the motherboard-SPDIF OUT Jan 14, 2024 pm 04:42 PM

SPDIFOUT connection line sequence on the motherboard. Recently, I encountered a problem regarding the wiring sequence of the wires. I checked online. Some information says that 1, 2, and 4 correspond to out, +5V, and ground; while other information says that 1, 2, and 4 correspond to out, ground, and +5V. The best way is to check your motherboard manual. If you can't find the manual, you can use a multimeter to measure it. Find the ground first, then you can determine the order of the rest of the wiring. How to connect motherboard VDG wiring When connecting the VDG wiring of the motherboard, you need to plug one end of the VGA cable into the VGA interface of the monitor and the other end into the VGA interface of the computer's graphics card. Please be careful not to plug it into the motherboard's VGA port. Once connected, you can

How to install and register the btc trading app? How to install and register the btc trading app? Feb 21, 2025 pm 07:09 PM

This article will provide a detailed introduction to how to install and register a Bitcoin trading application. The Bitcoin trading app allows users to manage and trade cryptocurrencies such as Bitcoin. The article guides users through the installation and registration process step by step, including downloading applications, creating accounts, performing identity verification, and first deposit. The goal of the article is to provide beginners with clear and easy-to-understand guidelines to help them easily enter the world of Bitcoin trading.

Top 10 global digital currency trading apps recommended (2025 currency trading software ranking) Top 10 global digital currency trading apps recommended (2025 currency trading software ranking) Mar 12, 2025 pm 05:48 PM

This article recommends the top ten digital currency trading apps in the world, including Binance, OKX, Huobi Global, Coinbase, Kraken, Gate.io, KuCoin, Bitfinex, Gemini and Bitstamp. These platforms have their own characteristics in terms of transaction pair quantity, transaction speed, security, compliance, user experience, etc. For example, Binance is known for its high transaction speed and extensive services, while Coinbase is more suitable for novices. Choosing a platform that suits you requires comprehensive consideration of your own needs and risk tolerance. Learn about the world's mainstream digital currency trading platforms to help you conduct digital asset trading safely and efficiently.

Ouyi Exchange Download Official Portal Ouyi Exchange Download Official Portal Feb 21, 2025 pm 07:51 PM

Ouyi, also known as OKX, is a world-leading cryptocurrency trading platform. The article provides a download portal for Ouyi's official installation package, which facilitates users to install Ouyi client on different devices. This installation package supports Windows, Mac, Android and iOS systems. Users can choose the corresponding version to download according to their device type. After the installation is completed, users can register or log in to the Ouyi account, start trading cryptocurrencies and enjoy other services provided by the platform.

Which digital currency app trading software is the best? Digital currency trading software big spot Which digital currency app trading software is the best? Digital currency trading software big spot Mar 07, 2025 pm 06:45 PM

There is no single "best" digital currency trading app, and the choice depends on personal needs. 1. OKX has powerful functions and rich currency types; 2. Binance has high liquidity and diverse transaction types; 3. Gate.io provides unique functions such as staking mining; 4. Huobi Global has a friendly interface and multi-language support; 5. Kraken focuses on security; 6. Coinbase is suitable for beginners and focuses on user education. When choosing, you need to consider security, liquidity, handling fees, functions, user experience and other factors.

Top 10 virtual digital currency trading platforms 2025 rankings, top ten virtual currency app exchanges Top 10 virtual digital currency trading platforms 2025 rankings, top ten virtual currency app exchanges Feb 21, 2025 pm 09:03 PM

This article introduces 10 mainstream cryptocurrency exchanges, covering basic information such as their establishment time, service scope, security, liquidity, transaction fees, etc. These exchanges include: OKX, Binance, Gate.io, Bitget, Coinbase, Huobi, KuCoin, Crypto.com, Gemini and Kraken.

Digital currency trading platform 2025 Digital currency trading platform 2025 Mar 04, 2025 pm 07:06 PM

Based on global information, this article compiles the rankings of the world's leading virtual digital currency trading platforms, including Binance, OKX, Gate.io, Huobi, Coinbase, Kraken, Crypto.com, bitget, KuCoin and Bitstamp. These platforms have their own characteristics in terms of user count, transaction volume, transaction types, security, compliance, etc. For example, Binance is known for its large user base and extensive trading options, while Coinbase is known for its leadership and ease of use in the US market. Choosing a suitable trading platform requires weighing factors such as security, fees, and trading products based on your own needs.

What is Ouyi Exchange? What is the use of Ouyi Exchange? What is Ouyi Exchange? What is the use of Ouyi Exchange? Feb 15, 2025 pm 08:57 PM

Ouyi Exchange, formerly known as Binance, is one of the world's leading cryptocurrency trading platforms. It was founded in 2017 by Zhao Changpeng and is headquartered in Hong Kong, China. Ouyi Exchange provides users with a wide range of cryptocurrency trading services, including spot trading, futures trading, over-the-counter trading and crypto asset management.

See all articles