日志损坏时的恢复

1.  当前日志组文件损坏----文件大小没有变化
SQL> startup
ORACLE instance started.
Total System Global Area  101784276 bytes
Fixed Size                   453332 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
ORA-00366: log 1 of thread 1, checksum error in the file header
ORA-00312: online log 1 thread 1: 'C:\SOFTWARE\ORACLE\ORADATA\MYDATA\REDO01.LOG'

SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          9   10485760          1 NO  CURRENT                1284414 24-APR-07
         2          1          8   10485760          1 YES INACTIVE               1284388 24-APR-07

SQL> alter database clear logfile group 1;
alter database clear logfile group 1
*
ERROR at line 1:
ORA-00350: log 1 of thread 1 needs to be archived
ORA-00312: online log 1 thread 1: 'C:\SOFTWARE\ORACLE\ORADATA\MYDATA\REDO01.LOG'

SQL> alter database clear unarchived logfile group 1;
alter database clear unarchived logfile group 1
*
ERROR at line 1:
ORA-00341: log 1 of thread 1, wrong log # 2 in header
ORA-00312: online log 1 thread 1: 'C:\SOFTWARE\ORACLE\ORADATA\MYDATA\REDO01.LOG'

SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          0   10485760          1 NO  CLEARING_CURRENT       1284414 24-APR-07
         2          1          0   10485760          1 YES UNUSED                       0 24-APR-07


......利用以前日志文件的备份(拷贝到当前位置)
SQL> alter database clear unarchived logfile group 1;
Database altered.
SQL> alter database open;
Database altered.
SQL>

......没有该日志文件的备份
SQL> startup
ORACLE instance started.
Total System Global Area  101784276 bytes
Fixed Size                   453332 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: 'C:\SOFTWARE\ORACLE\ORADATA\MYDATA\REDO01.LOG'

SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          1   10485760          1 NO  CURRENT                1284730 24-APR-07
         2          1          0   10485760          1 YES UNUSED                       0

SQL> alter database clear logfile group 1;
alter database clear logfile group 1
*
ERROR at line 1:
ORA-00350: log 1 of thread 1 needs to be archived
ORA-00312: online log 1 thread 1: 'C:\SOFTWARE\ORACLE\ORADATA\MYDATA\REDO01.LOG'

SQL> alter database clear unarchived logfile group 1;
alter database clear unarchived logfile group 1
*
ERROR at line 1:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: 'C:\SOFTWARE\ORACLE\ORADATA\MYDATA\REDO01.LOG'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) 系统找不到指定的文件。

SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          0   10485760          1 NO  CLEARING_CURRENT       1284730 24-APR-07
         2          1          0   10485760          1 YES UNUSED                       0

SQL> recover database until cancel;
Media recovery complete.
SQL> alter database open resetlogs;
Database altered.
SQL>


2.  当前日志组文件损坏----文件大小有变化
SQL> startup
ORACLE instance started.
Total System Global Area  101784276 bytes
Fixed Size                   453332 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: 'C:\SOFTWARE\ORACLE\ORADATA\MYDATA\REDO01.LOG'

SQL> alter database clear logfile group 1;
alter database clear logfile group 1
*
ERROR at line 1:
ORA-00350: log 1 of thread 1 needs to be archived
ORA-00312: online log 1 thread 1: 'C:\SOFTWARE\ORACLE\ORADATA\MYDATA\REDO01.LOG'

SQL> alter database clear unarchived logfile group 1;
alter database clear unarchived logfile group 1
*
ERROR at line 1:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: 'C:\SOFTWARE\ORACLE\ORADATA\MYDATA\REDO01.LOG'
ORA-27046: file size is not a multiple of logical block size
OSD-04012: file size mismatch (OS 10486270)

可以用上面 1 的方法解决


3.  非当前日志组文件损坏
(文件丢失, 文件损坏都可以这样)
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          1   10485760          1 NO  CURRENT                1285050 24-APR-07
         2          1          0   10485760          1 YES UNUSED                       0

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.
Total System Global Area  101784276 bytes
Fixed Size                   453332 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: 'C:\SOFTWARE\ORACLE\ORADATA\MYDATA\REDO02.LOG'

SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          1   10485760          1 NO  CURRENT                1285050 24-APR-07
         2          1          0   10485760          1 YES UNUSED                       0

SQL> alter database clear logfile group 2;
Database altered.

SQL> alter database open;
Database altered.
SQL>

原文地址:https://www.cnblogs.com/jasonsfu/p/1152795.html