归档模式下current logfile丢失或损坏恢复

+++++Session 1

SQL> set linesize 200 pagesize 2000
SQL> col member format a50
SQL> select * from v$log;

GROUP#   THREAD#  SEQUENCE#  BYTES  BLOCKSIZE MEMBERS ARC  STATUS    FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- -------------- -------------------------------
  1    1       4   52428800    512  1     NO   CURRENT  1670955       29-DEC-15  2.8147E+14
  2    1       2   20971520    512  1    YES  INACTIVE  1670943       29-DEC-15  1670949     29-DEC-15
  3    1       3   52428800    512  1    YES  INACTIVE  1670949       29-DEC-15  1670955     29-DEC-15

  
SQL>  select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER           IS_
---------- ------- ------- ------------------------------------------
  1    ONLINE  /u01/app/oracle/oradata/orcl/redo01.log       NO
  2    ONLINE  /u01/app/oracle/oradata/orcl/redo02.log       NO
  3    ONLINE  /u01/app/oracle/oradata/orcl/redo03.log       NO
 
SQL&get; alter system switch logfile;

System altered.

++++Session 2

[root@zw_test_26_75 ~]#  dd if=/dev/null of=/u01/app/oracle/oradata/orcl/redo01.log bs=512 count=10
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0.000121435 s, 0.0 kB/s
 

++++Session 1

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

SQL> startup
ORACLE instance started.

Total System Global Area  952020992 bytes
Fixed Size      2258960 bytes
Variable Size    314574832 bytes
Database Buffers   629145600 bytes
Redo Buffers      6041600 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/orcl/redo01.log'
ORA-27048: skgfifi: file header information is invalid
Additional information: 13

SQL> recover database until cancel;
Media recovery complete.

alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00327: log 2 of thread 1, physical size  less than needed
ORA-00312: online log 2 thread 1: '/home/ora10g/oradata/roger/redo02.log'

创建pfile添加隐含参数
#*._allow_resetlogs_corruption=true
#*._allow_error_simulation=true

SQL> startup mount pfile='/tmp/pfile.ora';
ORACLE instance started.

Total System Global Area  952020992 bytes
Fixed Size      2258960 bytes
Variable Size    314574832 bytes
Database Buffers   629145600 bytes
Redo Buffers      6041600 bytes
Database mounted.

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01139: RESETLOGS option only valid after an incomplete database recovery

SQL> recover database until cancel;
ORA-00283: recovery session canceled due to errors
ORA-16433: The database must be opened in read/write mode.

或者下面那个错

SQL> recover database until cancel;
ORA-00283: recovery session canceled due to errors
ORA-00600: internal error code, arguments: [2130], [0], [8], [2], [], [], [], []

SQL> show parameter resetlog

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
_allow_resetlogs_corruption      boolean  TRUE
SQL> show parameter allow

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
_allow_error_simulation       boolean  TRUE
_allow_resetlogs_corruption      boolean  TRUE
SQL> alter database open;

Database altered.

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /

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

[oracle@zw_test_26_75 tmp]$ vi pfile.ora
去掉隐含参数
#*._allow_resetlogs_corruption=true
#*._allow_error_simulation=true

SQL> startup
ORACLE instance started.

Total System Global Area  952020992 bytes
Fixed Size      2258960 bytes
Variable Size    314574832 bytes
Database Buffers   629145600 bytes
Redo Buffers      6041600 bytes
Database mounted.
Database opened.