【恢复,1】 redo 日志恢复的各种情况
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 |
---|---|
|
The online redo log has never been written to. |
|
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. |
|
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. |
|
The log is being re-created as an empty log after an |
|
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. |
|
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 isINVALID
if the file is inaccessible:SELECT GROUP#, STATUS, MEMBER
FROM V$LOGFILE
WHERE STATUS='INVALID'; GROUP# STATUS MEMBER
------- ----------- ---------------------
0002 INVALID /disk1/oradata/trgt/redo02.logDrop the damaged member. For example, to drop member
redo02.log
from group2
, 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 group2
, 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 试着运行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.fDetermine 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 NOPerform 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
statement as described in this section.
CLEAR LOGFILE
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, 须要清除日志后使数据文件上线,那么此时须要使用keywordUNRECOVERABLE 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
CANCELOpen 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
【恢复,1】 redo 日志恢复的各种情况的更多相关文章
- 【恢复】Redo日志文件丢失的恢复
第一章 Redo文件丢失的恢复 1.1 online redolog file 丢失 联机Redo日志是Oracle数据库中比较核心的文件,当Redo日志文件异常之后,数据库就无法正常启动,而且有丢 ...
- 通过 redo日志恢复数据库
如果还原存档的重做日志文件和数据文件,则必须先执行介质恢复,然后才能打开数据库.归档重做日志文件中未反映在数据文件中的任何数据库事务都将应用于数据文件,从而在打开数据库之前将它们置于事务一致状态. 介 ...
- Redo日志
undo日志有一个潜在的问题,即我们在将书屋改变的所有数据写到磁盘前不能提交该事务.有时,如果让数据库修改暂时只存在于主存中,我们可以节省磁盘IO;只要在崩溃发生时有日志可以恢复,这样做就是安全的. ...
- Oracle redo 日志损坏的几种情况下的恢复
Oracle redo 日志损坏的几种情况下的恢复 第一:损坏的redo为非正在使用的redo log 1.归档模式,不是当前正在日志损坏,数据库打开模式. 模拟损坏:SQL> select * ...
- Oracle非重要文件恢复,redo、暂时文件、索引文件、password文件
增量备份的应用在recovery阶段.不再restore阶段 了解数据库设置表: SQL>desc database_properties Name ...
- 【恢复】 Redo文件丢失的恢复
第一章 Redo文件丢失的恢复 1.1 online redolog file 丢失 联机Redo日志是Oracle数据库中比较核心的文件,当Redo日志文件异常之后,数据库就无法正常启动,而且有丢 ...
- 浅谈SQL Server中的事务日志(四)----在完整恢复模式下日志的角色
简介 生产环境下的数据是如果可以写在资产负债表上的话,我想这个资产所占的数额一定不会小.而墨菲定律(事情如果有变坏的可能,无论这种可能性有多小,它总会发生)仿佛是给DBA量身定做的.在上篇文章介绍的简 ...
- 数据误操作,删库跑路?教你使用ApexSQLLog工具从 SQLServer日志恢复数据!
前几天同事不小心误操作,将SQLServer库的一张表的一个状态字段给刷成了一个统一状态,由于是update执行所以原来的相关状态无法确定.发生这种事情的时候我的小伙伴背后 一凉,估计心里里面想这怕是 ...
- SQL Server中的事务日志管理(6/9):大容量日志恢复模式里的日志管理
当一切正常时,没有必要特别留意什么是事务日志,它是如何工作的.你只要确保每个数据库都有正确的备份.当出现问题时,事务日志的理解对于采取修正操作是重要的,尤其在需要紧急恢复数据库到指定点时.这系列文章会 ...
随机推荐
- python开发_pickle
pickle模块使用的数据格式是python专用的,并且不同版本不向后兼容,同时也不能被其他语言说识别.要和其他语言交互,可以使用内置的json包使用pickle模块你可以把Python对象直接保存到 ...
- wampserver3.1.0安装及配置
安装篇 环境:win10 64位+wamp3.1.0 为什么安装wamp3.1.0呢?php7早已正式发布了,还没有尝过鲜呢.点击进入wampserver下载地址 本以为下载后,执行exe文件,点ne ...
- reservoid sample 蓄水池问题
题目:怎样从无穷尽流中等概率的抽样出一个单词? 也许我们换一种说法会更加easy理解.等概率的抽取出一个单词,也即随机的抽取一个单词. 本体的难点在于没有给定单词数,而是一个无尽的流. 这个问题能够用 ...
- AskUsingForm_c函数
IDA SDK里面提供的UI(user interface)函数 AskUsingForm_c,该函数弹出一个对话框,而对话框的外观形式,就由此函数的第一个参数form(const char *类型) ...
- 掌握11项技能,你就是优秀的前端开发project师
导读: 你或许会认为前端开发是一个非常easy的工作,对呀,你就是刚刚从网页设计转型过来的.但当你深入当中时,一定会发现好像前端开发不是那么简单,光站点性能优化.响应式.框架就让你焦头烂额, 确实,做 ...
- 解决win8/8.1系统安装.net framework 3.5出现0x800F0906代码错误
解决方案一. 首先打开windows更新,检查是否有系统更新要安装,因为这个问题可能是导致.net 3.5无法安装的罪魁祸首,要检查windows更新,可以右键“这台电脑”点击“属性”,打开后,点击左 ...
- Excel实现二级菜单联动
项目中需要导入一个Excel模板需要实现二级联动,现记录如下: 首先看一下原始数据,原始信息在一张工作表,第一行是省市名称,下面的若干行为对应省市下面的地名和区名.需要在另外一张工作表中A列和B列建立 ...
- leetcode mock Shuffle an Array
1. shuffle算法: http://www.cnblogs.com/huaping-audio/archive/2008/09/09/1287985.html 注意:我们一般用的是第二种swap ...
- [Python爬虫] 之二:Selenium 调用IEDriverServer打开IE浏览器安装配置
无论是selenium2(WebDriver)还是selenium2Library,如果想要调用ie浏览器,均需以下步骤. 下载IEDriverServer.进入索引页,首先选择版本号,IEDrive ...
- Android -- ContentProvider与联系人
数据库 读联系人 raw ...