Oracle redo 日志损坏的几种情况下的恢复

第一:损坏的redo为非正在使用的redo log

1、归档模式,不是当前正在日志损坏,数据库打开模式。

模拟损坏:
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---
         1          1        388   52428800        512          1 YES INACTIVE               5385552 27-OCT-13      5385555 27-OCT-13
         2          1        389   52428800        512          1 YES INACTIVE               5385555 27-OCT-13      5385558 27-OCT-13
         3          1        390   52428800        512          1 NO  CURRENT                5385558 27-OCT-13   2.8147E+14
         4          1        387   52428800        512          1 YES INACTIVE               5385548 27-OCT-13      5385552 27-OCT-13
SQL> !rm redo02.log
SQL> !ls -l
total 3647744
-rw-r-----. 1 oracle oinstall   9977856 Oct 27 17:36 control01.ctl
-rw-r-----. 1 oracle oinstall 362422272 Oct 27 17:35 example01.dbf
-rw-r-----. 1 oracle oinstall  62922752 Oct 27 17:35 index_tablespace.dbf
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 17:35 redo01.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 17:35 redo03.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 17:35 redo04.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 25 16:45 redo4_1.log
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 17:35 Rhys_Amy.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 17:35 statspack.dbf
-rw-r-----. 1 oracle oinstall 671096832 Oct 27 17:35 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 796925952 Oct 27 17:35 system01.dbf
-rw-r-----. 1 oracle oinstall  44048384 Oct 27 16:18 temp01.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 17:35 undotbs02.dbf
-rw-r-----. 1 oracle oinstall   5251072 Oct 27 17:35 users01.dbf
SQL> 
日志提示错误:
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/rhys/RHYS/trace/RHYS_arc2_1758.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/opt/app/oracle/oradata/RHYS/redo02.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Master background archival failure: 313
日常出现错误,提示不能获得该文件状态,数据无法进行日志切换
解决办法
1、注意不需要重启数据库,只需要把日志清除即可。
SQL> alter database clear unarchived logfile group 2;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> 
SQL> !ls -l
total 3698948
-rw-r-----. 1 oracle oinstall   9977856 Oct 27 17:41 control01.ctl
-rw-r-----. 1 oracle oinstall 362422272 Oct 27 17:39 example01.dbf
-rw-r-----. 1 oracle oinstall  62922752 Oct 27 17:39 index_tablespace.dbf
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 17:40 redo01.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 17:41 redo02.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 17:38 redo03.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 17:38 redo04.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 25 16:45 redo4_1.log
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 17:39 Rhys_Amy.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 17:39 statspack.dbf
-rw-r-----. 1 oracle oinstall 671096832 Oct 27 17:39 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 796925952 Oct 27 17:39 system01.dbf
-rw-r-----. 1 oracle oinstall  44048384 Oct 27 16:18 temp01.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 17:39 undotbs02.dbf
-rw-r-----. 1 oracle oinstall   5251072 Oct 27 17:39 users01.dbf

2、归档模式,不是当前正在日志损坏,数据库关闭模式。

演示过程:
SQL> set linesize 200
SQL> select * from v$log;
select * from v$log
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

SQL> startup mount;
ORACLE instance started.
Total System Global Area  492707840 bytes
Fixed Size                  2254544 bytes
Variable Size             322963760 bytes
Database Buffers          163577856 bytes
Redo Buffers                3911680 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 3489
Session ID: 1 Serial number: 5
日志提示:
Errors in file /opt/app/oracle/diag/rdbms/rhys/RHYS/trace/RHYS_ora_3489.trc:
ORA-00313: open failed for members of log group 1 of thread
ORA-00312: online log 2 thread 1: '/opt/app/oracle/oradata/RHYS/redo02.log'
Sun Oct 27 17:45:25 2013
ARC1 started with pid=21, OS id=3493
USER (ospid: 3489): terminating the instance due to error 313
Sun Oct 27 17:45:25 2013
System state dump requested by (instance=1, osid=3489), summary=[abnormal instance termination].
System State dumped to trace file /opt/app/oracle/diag/rdbms/rhys/RHYS/trace/RHYS_diag_3458_20131027174525.trc
Dumping diagnostic data in directory=[cdmp_20131027174525], requested by (instance=1, osid=3489), summary=[abnormal instance termination].
Instance terminated by USER, pid = 3489
解决办法
在数据库启动的时候清除日志,然后open数据库:
SQL> startup mount;
ORACLE instance started.
Total System Global Area  492707840 bytes
Fixed Size                  2254544 bytes
Variable Size             322963760 bytes
Database Buffers          163577856 bytes
Redo Buffers                3911680 bytes
Database mounted.
SQL> alter database clear logfile group 2;
alter database clear logfile group 2
*
ERROR at line 1:
ORA-00350: log 2 of instance RHYS (thread 1) needs to be archived
ORA-00312: online log 2 thread 1: '/opt/app/oracle/oradata/RHYS/redo02.log'

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

3、数据库打开模式,非归档模式,非当前日志损坏

模拟过程:
SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     402
Current log sequence           405
SQL> !rm redo02.log
SQL> !ls -l
total 3647744
-rw-r-----. 1 oracle oinstall   9977856 Oct 27 17:54 control01.ctl
-rw-r-----. 1 oracle oinstall 362422272 Oct 27 17:54 example01.dbf
-rw-r-----. 1 oracle oinstall  62922752 Oct 27 17:54 index_tablespace.dbf
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 17:54 redo01.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 17:54 redo03.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 17:54 redo04.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 25 16:45 redo4_1.log
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 17:54 Rhys_Amy.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 17:54 statspack.dbf
-rw-r-----. 1 oracle oinstall 671096832 Oct 27 17:54 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 796925952 Oct 27 17:54 system01.dbf
-rw-r-----. 1 oracle oinstall  44048384 Oct 27 16:18 temp01.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 17:54 undotbs02.dbf
-rw-r-----. 1 oracle oinstall   5251072 Oct 27 17:54 users01.dbf
SQL> r
  1* alter system switch logfile
System altered.
SQL> r
  1* alter system switch logfile
System altered.
SQL> r
  1* alter system switch logfile
System altered.
SQL> r
  1* alter system switch logfile
System altered.
SQL> r
  1* alter system switch logfile
System altered.
SQL> r
  1* alter system switch logfile
System altered.
SQL> r
  1* alter system switch logfile
System altered.
SQL> r
  1* alter system switch logfile

SQL> 
在执行dml语句,以及切换日志都成功,但是数据库启动后报错。
日志文件如下:
Errors in file /opt/app/oracle/diag/rdbms/rhys/RHYS/trace/RHYS_ora_3779.trc:
ORA-00313: open failed for members of log group 1 of thread 
ORA-00312: online log 2 thread 1: '/opt/app/oracle/oradata/RHYS/redo02.log'
USER (ospid: 3779): terminating the instance due to error 313
System state dump requested by (instance=1, osid=3779), summary=[abnormal instance termination].
System State dumped to trace file /opt/app/oracle/diag/rdbms/rhys/RHYS/trace/RHYS_diag_3749_20131027175926.trc
Dumping diagnostic data in directory=[cdmp_20131027175926], requested by (instance=1, osid=3779), summary=[abnormal instance termination].
Instance terminated by USER, pid = 3779
解决方案
只需要把损坏的日志文件清除日志组即可。
SQL> startup mount;
ORACLE instance started.
Total System Global Area  492707840 bytes
Fixed Size                  2254544 bytes
Variable Size             322963760 bytes
Database Buffers          163577856 bytes
Redo Buffers                3911680 bytes
Database mounted.
SQL> alter database clear logfile group 2;
Database altered.
SQL> alter database open;
Database altered.
SQL>

4、非归档模式、数据库关闭、不是正在使用的日志文件损坏。

模拟过程:
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
         1          1        450   52428800        512          1 NO  CURRENT                5388976 27-OCT-13   2.8147E+14
         2          1        449   52428800        512          1 NO  INACTIVE               5388970 27-OCT-13      5388976 27-OCT-13
         3          1        447   52428800        512          1 NO  INACTIVE               5388964 27-OCT-13      5388967 27-OCT-13
         4          1        448   52428800        512          1 NO  INACTIVE               5388967 27-OCT-13      5388970 27-OCT-13
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !rm redo02.log
SQL> !ls -l
total 3647744
-rw-r-----. 1 oracle oinstall   9977856 Oct 27 18:06 control01.ctl
-rw-r-----. 1 oracle oinstall 362422272 Oct 27 18:06 example01.dbf
-rw-r-----. 1 oracle oinstall  62922752 Oct 27 18:06 index_tablespace.dbf
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 18:06 redo01.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 18:05 redo03.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 18:05 redo04.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 25 16:45 redo4_1.log
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 18:06 Rhys_Amy.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 18:06 statspack.dbf
-rw-r-----. 1 oracle oinstall 671096832 Oct 27 18:06 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 796925952 Oct 27 18:06 system01.dbf
-rw-r-----. 1 oracle oinstall  44048384 Oct 27 16:18 temp01.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 18:06 undotbs02.dbf
-rw-r-----. 1 oracle oinstall   5251072 Oct 27 18:06 users01.dbf
SQL> startup 
ORACLE instance started.
Total System Global Area  492707840 bytes
Fixed Size                  2254544 bytes
Variable Size             322963760 bytes
Database Buffers          163577856 bytes
Redo Buffers                3911680 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 4087
Session ID: 1 Serial number: 5
日志告警
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/rhys/RHYS/trace/RHYS_ora_4087.trc:
ORA-00313: open failed for members of log group 1 of thread 
ORA-00312: online log 2 thread 1: '/opt/app/oracle/oradata/RHYS/redo02.log'
USER (ospid: 4087): terminating the instance due to error 313
System state dump requested by (instance=1, osid=4087), summary=[abnormal instance termination].
System State dumped to trace file /opt/app/oracle/diag/rdbms/rhys/RHYS/trace/RHYS_diag_4057_20131027180649.trc
Dumping diagnostic data in directory=[cdmp_20131027180649], requested by (instance=1, osid=4087), summary=[abnormal instance termination].
Instance terminated by USER, pid = 4087
恢复方法
SQL> startup mount; 
ORACLE instance started.
Total System Global Area  492707840 bytes
Fixed Size                  2254544 bytes
Variable Size             322963760 bytes
Database Buffers          163577856 bytes
Redo Buffers                3911680 bytes
Database mounted.
SQL> alter database clear logfile group 2;
Database altered.
SQL> alter database open;
Database altered.
SQL> 
该方法与第三中方法一样。
总结,对于不是当前使用的归档日志损坏,归档模式需要使用alter database clear unarchived 命令清空日志 组即可。对于非归档模式需要使用alter system clear 日志文件组即可。

第二、当前正在使用的日志文件损坏

1、归档模式,数据库open状态、当前正在使用的日志文件损坏

模拟过程:
QL> !ls -l
total 3698948
-rw-r-----. 1 oracle oinstall   9977856 Oct 27 18:27 control01.ctl
-rw-r-----. 1 oracle oinstall 362422272 Oct 27 18:10 example01.dbf
-rw-r-----. 1 oracle oinstall  62922752 Oct 27 18:10 index_tablespace.dbf
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 18:26 redo01.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 18:10 redo02.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 18:10 redo03.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 18:10 redo04.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 25 16:45 redo4_1.log
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 18:10 Rhys_Amy.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 18:10 statspack.dbf
-rw-r-----. 1 oracle oinstall 671096832 Oct 27 18:26 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 796925952 Oct 27 18:26 system01.dbf
-rw-r-----. 1 oracle oinstall  44048384 Oct 27 16:18 temp01.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 18:26 undotbs02.dbf
-rw-r-----. 1 oracle oinstall   5251072 Oct 27 18:10 users01.dbf
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     447
Next log sequence to archive   450
Current log sequence           450
SQL> set linesize 200
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
         1          1        450   52428800        512          1 NO  CURRENT                5388976 27-OCT-13   2.8147E+14
         2          1          0   52428800        512          1 YES UNUSED                 5388970 27-OCT-13      5388976 27-OCT-13
         3          1        447   52428800        512          1 YES INACTIVE               5388964 27-OCT-13      5388967 27-OCT-13
         4          1        448   52428800        512          1 YES INACTIVE               5388967 27-OCT-13      5388970 27-OCT-13
SQL> !rm redo01.log
SQL> !ls -l
total 3647744
-rw-r-----. 1 oracle oinstall   9977856 Oct 27 18:28 control01.ctl
-rw-r-----. 1 oracle oinstall 362422272 Oct 27 18:10 example01.dbf
-rw-r-----. 1 oracle oinstall  62922752 Oct 27 18:10 index_tablespace.dbf
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 18:10 redo02.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 18:10 redo03.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 18:10 redo04.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 25 16:45 redo4_1.log
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 18:10 Rhys_Amy.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 18:10 statspack.dbf
-rw-r-----. 1 oracle oinstall 671096832 Oct 27 18:28 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 796925952 Oct 27 18:28 system01.dbf
-rw-r-----. 1 oracle oinstall  44048384 Oct 27 16:18 temp01.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 18:28 undotbs02.dbf
-rw-r-----. 1 oracle oinstall   5251072 Oct 27 18:10 users01.dbf
SQL> 
日志信息提示:
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/rhys/RHYS/trace/RHYS_arc2_4228.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/opt/app/oracle/oradata/RHYS/redo01.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Master background archival failure: 313
解决方法
由于这个时候,虽然当前日志是正在被使用的,但是我们可以先进行切换日志之后,然后执行clear操作。
SQL> alter system checkpoint;
System altered.
SQL> !rm redo01.log;
SQL> alter system checkpoint;
System altered.
SQL> alter database clear unarchived logfile group 1;
alter database clear unarchived logfile group 1
*
ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of instance RHYS (thread 1)
ORA-00312: online log 1 thread 1: '/opt/app/oracle/oradata/RHYS/redo01.log'
SQL> alter database switch logfile;
alter database switch logfile
                      *
ERROR at line 1:
ORA-02000: missing ALL keyword
SQL> alter system switch logfile;
System altered.
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
         1          1        458   52428800        512          1 NO  INACTIVE               5397246 27-OCT-13      5397347 27-OCT-13
         2          1        459   52428800        512          1 NO  CURRENT                5397347 27-OCT-13   2.8147E+14
         3          1        456   52428800        512          1 YES INACTIVE               5397237 27-OCT-13      5397240 27-OCT-13
         4          1        457   52428800        512          1 YES INACTIVE               5397240 27-OCT-13      5397246 27-OCT-13
SQL> alter database clear unarchived logfile group 1;
Database altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> 
SQL> startup
ORACLE instance started.
Total System Global Area  492707840 bytes
Fixed Size                  2254544 bytes
Variable Size             322963760 bytes
Database Buffers          163577856 bytes
Redo Buffers                3911680 bytes
Database mounted.
Database opened.
SQL>

2、归档模式,数据库open状态、当前正在使用的日志文件损坏,并且正常关闭数据库。

模拟过程:
SQL> startup
ORACLE instance started.
Total System Global Area  492707840 bytes
Fixed Size                  2254544 bytes
Variable Size             322963760 bytes
Database Buffers          163577856 bytes
Redo Buffers                3911680 bytes
Database mounted.
Database opened.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     0
Next log sequence to archive   459
Current log sequence           459
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
         1          1          0   52428800        512          1 YES UNUSED                 5397246 27-OCT-13      5397347 27-OCT-13
         2          1        459   52428800        512          1 NO  CURRENT                5397347 27-OCT-13   2.8147E+14
         3          1        456   52428800        512          1 YES INACTIVE               5397237 27-OCT-13      5397240 27-OCT-13
         4          1        457   52428800        512          1 YES INACTIVE               5397240 27-OCT-13      5397246 27-OCT-13
SQL> !rm redo02.log;
SQL> !ls -ltr
total 3647744
-rw-r-----. 1 oracle oinstall  52429312 Oct 25 16:45 redo4_1.log
-rw-r-----. 1 oracle oinstall  44048384 Oct 27 19:21 temp01.dbf
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 19:26 redo01.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 19:26 redo03.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 19:26 redo04.log
-rw-r-----. 1 oracle oinstall 796925952 Oct 27 19:26 system01.dbf
-rw-r-----. 1 oracle oinstall 671096832 Oct 27 19:26 sysaux01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Oct 27 19:26 users01.dbf
-rw-r-----. 1 oracle oinstall 362422272 Oct 27 19:26 example01.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 19:26 statspack.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 19:26 Rhys_Amy.dbf
-rw-r-----. 1 oracle oinstall  62922752 Oct 27 19:26 index_tablespace.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 19:26 undotbs02.dbf
-rw-r-----. 1 oracle oinstall   9977856 Oct 27 19:27 control01.ctl
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area  492707840 bytes
Fixed Size                  2254544 bytes
Variable Size             322963760 bytes
Database Buffers          163577856 bytes
Redo Buffers                3911680 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 5110
Session ID: 1 Serial number: 5

SQL> select open_mode from v$database;
ERROR:
ORA-03114: not connected to ORACLE

SQL> exit
解决办法,只需要进行启动到mount状态下,然后clear损坏日志即可。
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@oracle-one RHYS]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Oct 27 19:28:33 2013
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area  492707840 bytes
Fixed Size                  2254544 bytes
Variable Size             322963760 bytes
Database Buffers          163577856 bytes
Redo Buffers                3911680 bytes
Database mounted.
SQL> alter database clear unarchived logfile group 2;
Database altered.
SQL> alter database open;
Database altered.
SQL>

3、归档模式,数据库open状态、当前正在使用的日志文件损坏,并且异常关闭数据库。

模拟过程:
SQL> set linesize 200;
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
         1          1        460   52428800        512          1 NO  CURRENT                5397348 27-OCT-13   2.8147E+14
         2          1          0   52428800        512          1 YES UNUSED                 5397347 27-OCT-13      5397348 27-OCT-13
         3          1        456   52428800        512          1 YES INACTIVE               5397237 27-OCT-13      5397240 27-OCT-13
         4          1        457   52428800        512          1 YES INACTIVE               5397240 27-OCT-13      5397246 27-OCT-13
SQL> !rm redo01.log
SQL> !ls -l
total 3647744
-rw-r-----. 1 oracle oinstall   9977856 Oct 27 19:32 control01.ctl
-rw-r-----. 1 oracle oinstall 362422272 Oct 27 19:29 example01.dbf
-rw-r-----. 1 oracle oinstall  62922752 Oct 27 19:29 index_tablespace.dbf
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 19:29 redo02.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 19:29 redo03.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 27 19:29 redo04.log
-rw-r-----. 1 oracle oinstall  52429312 Oct 25 16:45 redo4_1.log
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 19:29 Rhys_Amy.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 19:29 statspack.dbf
-rw-r-----. 1 oracle oinstall 671096832 Oct 27 19:29 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 796925952 Oct 27 19:29 system01.dbf
-rw-r-----. 1 oracle oinstall  44048384 Oct 27 19:21 temp01.dbf
-rw-r-----. 1 oracle oinstall 524296192 Oct 27 19:29 undotbs02.dbf
-rw-r-----. 1 oracle oinstall   5251072 Oct 27 19:29 users01.dbf
SQL> shutdown abort;
ORACLE instance shut down.
SQL> 
解决办法
这时候我们有两种办法,一种是使用备份进行恢复,另一种是使用隐含参数。介绍第二种:
SQL> set verify off
SQL> @getsp.sql
Enter value for par: allow_resetlogs_
KSPPINM                                            KSPPSTVL             KSPPDESC
-------------------------------------------------- -------------------- ------------------------------------------------------------
_allow_resetlogs_corruption                        FALSE                allow resetlogs even if it will cause corruption
SQL> 
该参数是在数据库 不一致的情况下,重置日志文件。
SQL> alter system set "_allow_resetlogs_corruption"=true scope=spfile;
System altered.
SQL> shutdown immediate
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL> startup;     
ORACLE instance started.
Total System Global Area  492707840 bytes
Fixed Size                  2254544 bytes
Variable Size             322963760 bytes
Database Buffers          163577856 bytes
Redo Buffers                3911680 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/opt/app/oracle/oradata/RHYS/redo01.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL> set linesize 200
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
         1          1        460   52428800        512          1 NO  CURRENT                5397348 27-OCT-13   2.8147E+14
         4          1        457   52428800        512          1 YES INACTIVE               5397240 27-OCT-13      5397246 27-OCT-13
         3          1        456   52428800        512          1 YES INACTIVE               5397237 27-OCT-13      5397240 27-OCT-13
         2          1          0   52428800        512          1 YES UNUSED                 5397347 27-OCT-13      5397348 27-OCT-13
SQL> alter database open resetlogs;
Database altered.
SQL> 
重建实例然后使用expdp和impdp,将数据导出在导入数据库
SQL> create directory expdp as '/opt/app/oracle/oradata';
Directory created.
然后导出数据重建数据库,在导入数据。
总结:对于当前正在使用的日志的损坏,一般通过备份来修复,如果不行只能采用第二种设置隐含参数_allow_resetlogs_corruption来恢复。

Oracle redo 日志损坏的几种情况下的恢复的更多相关文章

  1. Oracle联机日志损坏解决办法

    关于此问题,在网上找到一篇不错的文章. 大家都清楚,联机日志分为当前联机日志和非当前联机日志. ---------------------------------------------------- ...

  2. Oracle主库归档丢失,备库日志有gap,在不重建备库的情况下,恢复备库

    本文主要描述Oracle备库日志与主库日志之间有gap,切主库这部分gap的归档日志已经删除或丢失,如何在不重建备库的情况下,恢复备库. 欢迎转载,请注明作者.出处. 作者:张正 blog:http: ...

  3. 五种情况下会刷新控件状态(刷新所有子FWinControls的显示)——从DFM读取数据时、新增加子控件时、重新创建当前控件的句柄时、设置父控件时、显示状态被改变时

    五种情况下会刷新控件状态(刷新控件状态才能刷新所有子FWinControls的显示): 在TWinControls.PaintControls中,对所有FWinControls只是重绘了边框,而没有整 ...

  4. create-react-app:reject和不reject(使用react-app-rewired)这2种情况下的antd组件按需引入配置

    create-react-app:eject和不eject(使用react-app-rewired)这2种情况下的antd组件按需引入配置: 不eject(使用react-app-rewired)配置 ...

  5. Java实现PV操作 | 读者与写者(在三种情况下进行讨论)

    注 :本文应结合[天勤笔记]进行学习. 1.读者优先 设置rmutex信号量来对readcount变量进行互斥访问.mutex信号量对写者与读者进行同步. static syn rmutex=new ...

  6. 【DATAGUARD】物理dg在主库丢失归档文件的情况下的恢复(七)

    [DATAGUARD]物理dg在主库丢失归档文件的情况下的恢复(七) 一.1  BLOG文档结构图 一.2  前言部分 一.2.1  导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到 ...

  7. oracle redo日志文件损坏恢复

    参考:How to Recover from Loss Of Online Redo Log And ORA-312 And ORA-313 (Doc ID 117481.1) 在线重做日志文件丢失后 ...

  8. oracle redo日志维护

    环境 OS:Red Hat Linux As 5 DB:10.2.0.1 1.添加日志组 alter database add logfile group 4 ('/u01/app/oracle/or ...

  9. Oracle 无备份情况下的恢复--临时文件/在线重做日志/ORA-00205

    13.5 恢复临时文件 临时文件没有也不应该备份.通过V$TEMPFILE可以找到所有的临时文件. 此类文件的损坏会造成需要使用临时表空间的命令执行失败,不至于造成实例崩溃或session中断.由于临 ...

随机推荐

  1. codeforces 798C.Mike and gcd problem 解题报告

    题目意思:给出一个n个数的序列:a1,a2,...,an (n的范围[2,100000],ax的范围[1,1e9] ) 现在需要对序列a进行若干变换,来构造一个beautiful的序列: b1,b2, ...

  2. dp1--乘积最大

    dp1--乘积最大 一.心得 1.用excel填数组很方便 2. dp就是填表 找状态就是缩小规模 找状态转移方程就是 找状态的最后一次关系 二.题目 8782:乘积最大 查看 提交 统计 提问 总时 ...

  3. LeetCode OJ:Convert Sorted Array to Binary Search Tree(将排序好的数组转换成二叉搜索树)

    Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 讲一 ...

  4. Linux-压缩与解压缩命令

    常用的压缩格式:.zip   .gz   .bz2   .tar.gz   .tar.bz2 1.Zip 压缩文件:zip 压缩文件名  源文件 压缩目录:zip -r 压缩文件名 源文件 解压缩.z ...

  5. Codeforces Round #253 (Div. 2)B(暴力枚举)

    就暴力枚举所有起点和终点就行了. 我做这题时想的太多了,最简单的暴力枚举起始点却没想到...应该先想最简单的方法,层层深入. #include<iostream> #include< ...

  6. OpenCV - win7+vs2013(2012)+opencv3.0.0 环境配置 (以及配置技巧)

    1. opencv 3.0.0 库下载地址, 这里的版本是3.0.0,其他的版本配置可能不一样,请大家注意. http://sourceforge.net/projects/opencvlibrary ...

  7. 运动目标跟踪中kalman滤波器的使用

    目标跟踪的kalman滤波器介绍 Kalman滤波器是通过前一状态预测当前状态,并使用当前观测状态进行校正,从而保证输出状态平稳变化,可有效抵抗观测误差.因此在运动目标跟踪中也被广泛使用.在视频处理的 ...

  8. [独孤九剑]Oracle知识点梳理(六)数据库常用对象之Procedure、function、Sequence

    本系列链接导航: [独孤九剑]Oracle知识点梳理(一)表空间.用户 [独孤九剑]Oracle知识点梳理(二)数据库的连接 [独孤九剑]Oracle知识点梳理(三)导入.导出 [独孤九剑]Oracl ...

  9. javascript之面试题精讲

    from:http://blog.csdn.net/q121516340/article/details/51332454 1,检测数组的几种方式: Array.isArray(); es5 toSt ...

  10. htaccess不起作用的解决方法,AllowOverride All打开后出现403错误时解决办法

    在php程序的目录下有一个htaccess文件,这个文件起着对url重写的作用,但是不巧的,在我的应用程序里不起作用,baidu了一下,发现是 AllowOverride All,  这个选项没有打开 ...