Home Database Mysql Tutorial Oracle教程:实例故障恢复

Oracle教程:实例故障恢复

Jun 07, 2016 pm 05:03 PM
o database

调整实例恢复的持续时间:1.设置一些初始化参数影响恢复需要的refo log记录和数据块的数量;(新参数)FAST_START_MTTR_TARGET:指

MTBF:Mean-Time-Between-Failures两次故障之间的平均无故障时间
MTTR:Mean-Time-To-Recover故障恢复平均时间

故障分类:
1.SQL表达式引起的故障
BUG,非法数据,超过权限,配额限制
2.用户进程故障
断开连接,会话注销,用户进程BUG,PMON自动处理此故障
3.用户故障
人为清空、删除表
4.网络故障
断网
5.实例故障
断电,SMON进程处理此故障
6.介质故障
磁盘损坏,RMAN热备和dataguard容灾

内存结构
database buffer cache:存储从datafile中读取的blocks。数据由server process从数据文件读入database buffer cache,数据由DBWn进程从database buffer cache写入datafile;

redo log buffer:存储对数据库的任何改变,由LGWR写到redo logs

Large pool:可选组件,备份等需要使用的大内存

shared pool:存储已经解析的SQL表达式和PL/SQL过程,数据字典信息

java pool:存储java code和JVM

后台进程
DBWn(Database writer):把database buffer cache的脏数据(即已修改的数据)写到datafile。

LGWR(Log writer):把redo log buffer数据写到redo log files

SMON(System monitor):自动实例恢复,恢复临时段的空间当不再使用时,合并零散空间。

PMON(Process monitor):清理连接进程;回滚进程操作和资源。

CKPT(checkpoint) :把当前redo log信息同步到datafile和control files的头上。

ARCn(Archiver):可选,把redo logs自动复制到其他地方。

用户进程
连接数据库的程序进程,如:sqlplus

服务进程
接收用户进程请求,处理请求。专有服务进程和共享服务进程

数据库文件
Datafile:数据的物理存储,至少一个。
Redo logs:存储数据改变,至少2组。
Control files:记录了数据库的状态,物理结构,RMAN预处理数据
Archive logs :联机重做日志文件的物理备份。

initialization parameter file:Pfile文件,存储实例启动所需参数
Server initialization parameter file:SPfile文件,存储实例启动所需持久的参数,二进制文件。
Password file:存储能启动、停止和恢复数据库的特权用户的信息;二进制文件。可使用工具ORAPWD.EXE手工创建密码文件

动态视图
v$sga
v$sgastat
v$instance
v$process
v$bgprocess
v$database
v$datafile

large pool:用于Oracle备份和还原操作,I/O server processes,共享服务者(shared server)进程的会话内存。
配置large pool可以阻止RMAN在其它部件分配内存,RMAN用large pool进行备份和还原当你设置DBWR_IO_SLAVES或者BACKUP_TAPE_IO_SLAVES参数去模拟异步I/O时。如果2个参数都没设置,ORACLE会从local process memory分配备份缓冲区,而不是从shared pool。

如果large_pool_size参数被设置了,oracle会尝试去large pool获取内存。如果这个值不够大,oracle也不会尝试去shared pool获取缓冲区。如果没配置,oracle会分配共享内存缓冲区从shared pool。
如果orcle不能得到充足的内存,它就会从local process memory得到I/O缓冲区。而且会写信息到alert.log中,指出同步I/O被用于备份。

database buffer cache:用于存储大多数最近使用的数据块的区域,使用最近最少使用算法(LRU)去决定覆盖某些以用来容纳新的block。

DBWn:写修改过的数据到数据文件,以确保可以从datafile读取新的block到database buffer cache。周期性的同步database buffer cache和datafile(即把database buffer cache写回到datafile)。繁重的工作可配置20个DWBn进程,DBW0-DBW9,DBWA-DBWJ。

redo log buffer:是一个有对数据库改变信息的环形缓冲区,这些信息存储在redo entries。
redo entries包含需要重建或重做的信息,如INSERT、UPDATE、DELETE、CREATE、ALTER、DROP操作。redo entries用于数据库恢复,如果需要的话。redo entries被server process从用户内存空间复制到redo log buffer。

LGWR:当redo log buffer三分之一满,当每3秒,当有1MB的redo信息,当在DBWn写修改过的数据到数据文件之前,当commit时,写redo log file。

checkpoint position:恢复开始的地方,联机重做日志文件里的一个点。
它是checkpoint queue的第一个entry的开始标志。
例如:checkpoint这一点之前的redo log数据已被写到数据文件里。

checkpoint queue:内存中的队列链表。
checkpoint queue里的每个entry包含数据块的标识和与之相关的redo entry的信息。这样的一个entry被称为RBA(redo byte address)。DBWn读取checkpoint queue的一个entry写入数据文件后删除这个entry。

checkpoint的类型
FULL checkpoint:全checkpoint,把所有的buffer都写入数据文件。当shutdown normal,immediate,transactional和alter system checkpoint时发生。

Incremental checkpoint:增量checkpoint,周期性写,闲置时写。

partial checkpoint:部分checkpoint,,写表空间的脏数据。当alter tablespace begin backup和alter tablespace xxx offline normal。

CKPT:在检查点发生时通知DBWn进程去写datafile后,更新datafiles和control files的头去指出最近的checkpoint。每隔3秒,CKPT记录检查点队列里面的第一个entry的RBA信息到控制文件中。只有在日志切换的时候,CKPT才会更新数据文件的头,为了提高性能不会马上更新所有的头,而是“懒写”。日志切换时不会把所有的脏数据写到磁盘。

control file:二进制文件,它描述了数据库的结构,当数据库处于mount或open状态的时候它必须能被数据库服务器来写。它的名字取决于操作系统。没有这个文件数据库不能被mount。推荐配置最少2个控制文件放在不同的磁盘以减少控制文件丢失带来的影响。控制文件损坏一个数据库就不能工作。控制文件包含数据库名字、数据库创建的时间戳,恢复所需的同步信息、数据文件和联机重做日志文件的名字和位置、数据库的归档模式、当前log sequence number、RMAN的备份元信息。

archived log file:用作media recovery。当被设置为归档模式时,LGWR进程会等联机重做日志文件被归档后才继续工作。

ARCn:可选进程。当被启动时,它会把redo log files拷贝到指定的存储区域。这个进程对7*24数据库的备份恢复有很大的意见。当日志切换时,ARCn进程被触发,把最近没归档的redo log组的一个成员拷贝到指定位置。

数据库同步:
1.所有数据文件(除了离线与只读的)必须被同步后数据库才能被open。
2.同步是基于当前checkpoint number。
3.发现不同步,数据库使用redo log files改变的记录同步数据文件
4.redo log files自动被数据库服务器请求。

实例恢复:
1.判断数据文件是否同步;
2.利用redo log前滚:写redo log files最近一个checkpoint之后的数据(包括undo数据)到数据文件;
3.数据文件现在包含提交的和未提交的改变,数据库可以被open;
4.利用undo log回滚未提交的改变:删除datafile中未提交的数据;
5.至此所有数据都提交。
不像media recovery,crash recovery和instance recovery是自动的。crash recovery是所有实例都恢复,instance recovery是单实例恢复。

调整实例恢复的持续时间:
1.设置一些初始化参数影响恢复需要的refo log记录和数据块的数量;
(新参数)
FAST_START_MTTR_TARGET:指定恢复时间最大值,单位为秒。
(2个老参数)
LOG_CHECKPOINT_TIMEOUT:2次检查点发生间隔的时间。
LOG_CHECKPOINT_INTERVAL:增量检查点与最近写到redo log的块之间的redo log file块的数目。
2.控制redo log file的大小和refo log块的大小来影响checkpoint发生的频率;
3.用SQL表达式手动强制检查点发生
4.并行恢复

实例恢复视图v$instance_recovery;
实例恢复优化
1.前滚:采用并行块恢复策略,recovery_parallelism可以设置并行进程数。
2.回滚:采用急需和并发2种恢复策略,fast_start_parallel_rollback可以设置并行程度,false为不使用并行,low:回滚进程数为CPU数的2倍,high:回滚进程数为CPU数的4倍。
回滚对应的2个视图:v$fast_start_servers:并发进程的信息;v$fast_start_transactions:需要回滚的transaction信息。

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)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months 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)

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

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.

How to save JSON data to database in Golang? How to save JSON data to database in Golang? Jun 06, 2024 am 11:24 AM

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

How does Go WebSocket integrate with databases? How does Go WebSocket integrate with databases? Jun 05, 2024 pm 03:18 PM

How to integrate GoWebSocket with a database: Set up a database connection: Use the database/sql package to connect to the database. Store WebSocket messages to the database: Use the INSERT statement to insert the message into the database. Retrieve WebSocket messages from the database: Use the SELECT statement to retrieve messages from the database.

PHP Database Connection Pitfalls: Avoid Common Mistakes and Misunderstandings PHP Database Connection Pitfalls: Avoid Common Mistakes and Misunderstandings Jun 05, 2024 pm 10:21 PM

To avoid PHP database connection errors, follow best practices: check for connection errors and match variable names with credentials. Use secure storage or environment variables to avoid hardcoding credentials. Close the connection after use to prevent SQL injection and use prepared statements or bound parameters.

See all articles