处理Online redo log错误

Online redo logs是数据库中用于记录交易记录的关键组件,主要用于数据库故障后的恢复。每个数据库至少需要两个重做日志组,每个组至少一个成员文件。通过在组内创建多个成员实现重做日志的多重化,以减少错误导致的数据丢失。当发生介质失败时,检查alert.log文件确定受影响的日志文件,并查询V$LOG和V$LOGFILE以评估日志组状态和多重化程度,修复失败的成员以恢复数据库。

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

1:redo log 是如何工作的:

Online redo logs store a record of transactions that have occurred in your database. Online redo logs exist solely to provide a mechanism for you to recover your database in the event of a failure. You are required to have at least two online redo log groups in your database. Each online redo log group must contain at least one online redo log member. The member is the physical file that exists on disk. You can create multiple members in each redo log group, which is known as multiplexing your online redo log group.


NOTE:联机重做日志记录数据库发生的所有变化。联机重做日志采用循环些的处理方法

2:如何尽量减少redo错误造成的数据损失:

•Multiplex groups to have multiple members.

•Never allow two members of the same group to share the same controller.
•Never put two members of the same group on the same physical disk.
•Ensure operating system file permissions are set appropriately.
•Use physical storage devices that are redundant (that is, RAID).
•Appropriately size the log files so that they switch and are archived at regular intervals.
•Set the  archive_lag_targetinitialization parameter to ensure that the online redo logs

are switched at regular intervals


3:Determining How to Restore

  •  Inspect the alert.log file to determine which online redo log files have experienced a media failure.
  •  Query V$LOG and V$LOGFILE to determine the status of the log group and degree of multiplexing.
  •  If  there is still one functioning member of a multiplexed group, fix the remaining failed member(s).
  •  Depending on the status of the log group
select a.group#,a.thread# ,a.status ,b.member member,b.status from v$log a,v$logfile b where a.group#=b.group# order by a.group#,b.group#;

联机重做日志的状态:

CURRENT                               The log group that is currently being written to by the log writer.---当前正在使用
ACTIVE                                     The log group is required for crash recovery and may or may not have been archived.--用来crash恢复,有可能已经归档
CLEARING                              The log group is being cleared out by an  alter database clear  logfile command.--
CLEARING_CURRENT        The current log group is being cleared of a closed thread.
INACTIVE                                 The log group isn’t needed for crash recovery and may or may not have  been archived.
UNUSED                                   The log group has never been written to; it was recently created.

4: Restoring After Losing One Member of the  Multiplexed Group
现象:
Errors in file /oracle/admin/purple/bdump/purple_lgwr_4645.trc:
ORA-00321: log 2 of thread 1, cannot update log file header
ORA-00312: online log 2 thread 1: '/oracle/oradata/purple/redo02.log'
解决:
SQL> alter system archive log  current; --将发生错误的组状态置于NO CURRENT 
SQL> alter database drop logfile member '/oracle/oradata/purple/redo02.log';
SQL> alter database add logfile member '/oracle/oradata/purple/redo02.log' to group 2;
Database altered.

5:Recovering After Loss of All Members of the INACTIVE  Redo Log Group
[oracle@oracle10g purple]$ rm -rf redo02*
alter system archive log current
*
ERROR at line 1:
ORA-16038: log 2 sequence# 27 cannot be archived
ORA-00312: online log 2 thread 1: '/oracle/oradata/purple/redo021.log'
ORA-00312: online log 2 thread 1: '/oracle/oradata/purple/redo02.log'

解决:

SQL> alter database clear logfile group 2;
SQL> alter database clear unarchived logfile group 2;
SQL> alter database drop logfile group 2;
SQL> alter database add logfile group 2 ('/oracle/oradata/purple/redo02.LOG', '/oracle/oradata/purple/redo021.log') SIZE 50M;
Database altered.

6:Recovering After Loss of All Members of the ACTIVE  Redo Log Group

SQL>alter system checkpoint
SQL> alter database clear logfile group 2;
SQL> alter database clear unarchived logfile group 2;
SQL> alter database drop logfile group 2;
SQL> alter database add logfile group 2 ('/oracle/oradata/purple/redo02.LOG', '/oracle/oradata/purple/redo021.log') SIZE 50M;





7:Recovering After Loss of All Members of the CURRENT Redo Log Group

•Perform an incomplete recovery up to the last good SCN.
•If flashback is enabled, flash your database back to the last good SCN.
•If you’re using Oracle Data Guard, fail over to your physical or logical standby database.
•Contact Oracle Support for suggestions
SQL> shutdown immediate;
SQL> startup mount;
SQL> select group#, status, archived, thread#, sequence#, first_change# from v$log;
    GROUP# STATUS           ARC    THREAD#  SEQUENCE# FIRST_CHANGE#
---------- ---------------- --- ---------- ---------- -------------
         1 INACTIVE         YES          1         26        568581
         3 CURRENT          NO           1         28        568588
         2 UNUSED           YES          1          0             0

RMAN> restore database until scn 568588;
RMAN> recover database until scn 568588;
RMAN> alter database open resetlogs;

RMAN> list incarnation;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       PURPLE   2860377939       PARENT  1          22-OCT-05
2       2       PURPLE   2860377939       PARENT  525876     18-JAN-13
3       3       PURPLE   2860377939       CURRENT 568582     21-JAN-13



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值