恢复步骤:1.肯定是否有缺失的日志文件2.恢复丢失的文件时,先删除丢失的重作日志成员ALTER DATABASE DROP LOGFILE MEMBER '+DATA/orcl/onlinelog/group_1.261.691672257';3.而后添加新成员来替代丢失的日志成员ALTER DATABASE ADD LOGFILE MEMBER '+DATA' TO GROUP 2;4.若是介质故障是因为磁盘或控制器缺失而形成的,需重命名丢失文件。5.若是重作日志组已归档,或者处于NOARCHIVELOG模式下,则可选择在清除日志组后从新建立缺失来解决问题,ALTER DATABASE CLEAR LOGFILE GROUP n;注意:清除未归档的日志组,应当即对整个数据库执行彻底备份,不然,在发生其它故障的状况下,会致使数据丢失。ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP #;
alter database add logfile group 4 ('/u01/app/oracle/oradata/xiocpt0/p_redo04_01.log','/u01/app/oracle/oradata/xiocpt0/p_redo04_02.log') size 128M; alter database add logfile group 5 ('/u01/app/oracle/oradata/xiocpt0/p_redo05_01.log','/u01/app/oracle/oradata/xiocpt0/p_redo05_02.log') size 128M; alter database add logfile group 6 ('/u01/app/oracle/oradata/xiocpt0/p_redo06_01.log','/u01/app/oracle/oradata/xiocpt0/p_redo06_02.log') size 128M;
SQL> set pagesize 600 select group#,sequence#,bytes/(1024*1024),members,archived,status from v$log;--查看重作日志成员状态信息 col member format a50 SQL> SQL> GROUP# SEQUENCE# BYTES/(1024*1024) MEMBERS ARC STATUS ---------- ---------- ----------------- ---------- --- ---------------- 1 4 50 1 YES INACTIVE 2 5 50 1 NO CURRENT 3 3 50 1 YES INACTIVE 4 0 128 2 YES UNUSED 5 0 128 2 YES UNUSED 6 0 128 2 YES UNUSED 6 rows selected. SQL> select group#,status,member from v$logfile;--查看重作日志成员,物理路径,这里存储方式为文件系统 GROUP# STATUS MEMBER ---------- ------- -------------------------------------------------- 1 STALE /u01/app/oracle/oradata/xiocpt0/redo01.log 3 STALE /u01/app/oracle/oradata/xiocpt0/redo03.log 2 /u01/app/oracle/oradata/xiocpt0/redo02.log 4 /u01/app/oracle/oradata/xiocpt0/p_redo04_01.log 4 /u01/app/oracle/oradata/xiocpt0/p_redo04_02.log 5 /u01/app/oracle/oradata/xiocpt0/p_redo05_01.log 5 /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log 6 /u01/app/oracle/oradata/xiocpt0/p_redo06_01.log 6 /u01/app/oracle/oradata/xiocpt0/p_redo06_02.log 9 rows selected. 手动删除group 1的物理文件 SQL> !rm /u01/app/oracle/oradata/xiocpt0/redo01.log group 1的状态以归档,INACTIVE SQL> select group#,sequence#,bytes/(1024*1024),members,archived,status from v$log; GROUP# SEQUENCE# BYTES/(1024*1024) MEMBERS ARC STATUS ---------- ---------- ----------------- ---------- --- ---------------- 1 4 50 1 YES INACTIVE 2 5 50 1 NO CURRENT 3 3 50 1 YES INACTIVE 4 0 128 2 YES UNUSED 5 0 128 2 YES UNUSED 6 0 128 2 YES UNUSED 6 rows selected. 验证物理文件已被删除 SQL> !ls -l /u01/app/oracle/oradata/xiocpt0/redo01.log ls: cannot access /u01/app/oracle/oradata/xiocpt0/redo01.log: No such file or directory 针对已归档的重作日志文件组,可使用clear命令进行恢复 alter database clear logfile group 1; SQL> alter database clear logfile group 1; Database altered. 验证物理文件已恢复完成 SQL> !ls -l /u01/app/oracle/oradata/xiocpt0/redo01.log -rw-r----- 1 oracle dba 52429312 May 22 13:42 /u01/app/oracle/oradata/xiocpt0/redo01.log
SQL> select group#,sequence#,bytes/(1024*1024),members,archived,status from v$log; GROUP# SEQUENCE# BYTES/(1024*1024) MEMBERS ARC STATUS ---------- ---------- ----------------- ---------- --- ---------------- 1 6 50 1 YES INACTIVE 2 5 50 1 YES INACTIVE 3 3 50 1 YES INACTIVE 4 7 128 2 YES INACTIVE 5 8 128 2 YES INACTIVE 6 9 128 2 NO CURRENT 删除group 5中的 02成员 SQL> !ls -l /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log -rw-r----- 1 oracle dba 134218240 May 22 13:42 /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log SQL> !rm /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log SQL> !ls -l /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log ls: cannot access /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log: No such file or directory SQL> alter system switch logfile; System altered. SQL> / SQL> / SQL> / SQL> / SQL> alter system checkpoint; System altered. oracle预警日志文件中提示/u01/app/oracle/oradata/xiocpt0/p_redo05_02.log以不存在,由于重作日志group 5有2个成员,数据依旧正常。 Errors in file /u01/app/oracle/diag/rdbms/xiocpt0/xiocpt0/trace/xiocpt0_arc0_1460.trc: ORA-00313: open failed for members of log group 5 of thread 1 ORA-00312: online log 5 thread 1: '/u01/app/oracle/oradata/xiocpt0/p_redo05_02.log' ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3 Errors in file /u01/app/oracle/diag/rdbms/xiocpt0/xiocpt0/trace/xiocpt0_arc0_1460.trc: ORA-00313: open failed for members of log group 5 of thread 1 ORA-00312: online log 5 thread 1: '/u01/app/oracle/oradata/xiocpt0/p_redo05_02.log' ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory 对group有多个成员的,单成员进行修复 alter database drop logfile member '/u01/app/oracle/oradata/xiocpt0/p_redo05_02.log'; alter database add logfile member '/u01/app/oracle/oradata/xiocpt0/p_redo05_02.log' to group 5; 先将丢失的成员从group中进行删除 SQL> alter database drop logfile member '/u01/app/oracle/oradata/xiocpt0/p_redo05_02.log'; Database altered. SQL> select group#,sequence#,bytes/(1024*1024),members,archived,status from v$log; GROUP# SEQUENCE# BYTES/(1024*1024) MEMBERS ARC STATUS ---------- ---------- ----------------- ---------- --- ---------------- 1 12 50 1 YES INACTIVE 2 11 50 1 YES INACTIVE 3 16 50 1 NO CURRENT 4 13 128 2 YES INACTIVE 5 14 128 1 YES INACTIVE 6 15 128 2 YES INACTIVE 6 rows selected. 再新增成员 SQL> alter database add logfile member '/u01/app/oracle/oradata/xiocpt0/p_redo05_02.log' to group 5; Database altered. SQL> select group#,sequence#,bytes/(1024*1024),members,archived,status from v$log; GROUP# SEQUENCE# BYTES/(1024*1024) MEMBERS ARC STATUS ---------- ---------- ----------------- ---------- --- ---------------- 1 12 50 1 YES INACTIVE 2 11 50 1 YES INACTIVE 3 16 50 1 NO CURRENT 4 13 128 2 YES INACTIVE 5 14 128 2 YES INACTIVE 6 15 128 2 YES INACTIVE 6 rows selected. 也能够对整个group 进行clear,但需注意此group 必须已归档 SQL> !rm /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log SQL> !ls -l /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log ls: cannot access /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log: No such file or directory SQL> alter database clear logfile group 5; Database altered. SQL> !ls -l /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log -rw-r----- 1 oracle dba 134218240 May 22 13:51 /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log
SQL> select group#,sequence#,bytes/(1024*1024),members,archived,status from v$log; GROUP# SEQUENCE# BYTES/(1024*1024) MEMBERS ARC STATUS ---------- ---------- ----------------- ---------- --- ---------------- 1 12 50 1 YES INACTIVE 2 11 50 1 YES INACTIVE 3 16 50 1 NO CURRENT 4 13 128 2 YES INACTIVE 5 0 128 2 YES UNUSED 6 15 128 2 YES INACTIVE 6 rows selected. SQL> SQL> select group#,status,member from v$logfile; GROUP# STATUS MEMBER ---------- ------- -------------------------------------------------- 1 /u01/app/oracle/oradata/xiocpt0/redo01.log 3 /u01/app/oracle/oradata/xiocpt0/redo03.log 2 /u01/app/oracle/oradata/xiocpt0/redo02.log 4 /u01/app/oracle/oradata/xiocpt0/p_redo04_01.log 4 /u01/app/oracle/oradata/xiocpt0/p_redo04_02.log 5 /u01/app/oracle/oradata/xiocpt0/p_redo05_01.log 5 /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log 6 /u01/app/oracle/oradata/xiocpt0/p_redo06_01.log 6 /u01/app/oracle/oradata/xiocpt0/p_redo06_02.log 9 rows selected. SQL> !rm -rf /u01/app/oracle/oradata/xiocpt0/redo03.log SQL> !ls -l /u01/app/oracle/oradata/xiocpt0/redo03.log ls: cannot access /u01/app/oracle/oradata/xiocpt0/redo03.log: No such file or directory SQL> alter system switch logfile; System altered. SQL> alter system checkpoint; System altered. SQL> alter database clear unarchived logfile group 3; Database altered. SQL> select group#,status,member from v$logfile; GROUP# STATUS MEMBER ---------- ------- -------------------------------------------------- 1 /u01/app/oracle/oradata/xiocpt0/redo01.log 3 /u01/app/oracle/oradata/xiocpt0/redo03.log 2 /u01/app/oracle/oradata/xiocpt0/redo02.log 4 /u01/app/oracle/oradata/xiocpt0/p_redo04_01.log 4 /u01/app/oracle/oradata/xiocpt0/p_redo04_02.log 5 /u01/app/oracle/oradata/xiocpt0/p_redo05_01.log 5 /u01/app/oracle/oradata/xiocpt0/p_redo05_02.log 6 /u01/app/oracle/oradata/xiocpt0/p_redo06_01.log 6 /u01/app/oracle/oradata/xiocpt0/p_redo06_02.log 9 rows selected. SQL> !ls -l /u01/app/oracle/oradata/xiocpt0/redo03.log -rw-r----- 1 oracle dba 52429312 May 22 13:52 /u01/app/oracle/oradata/xiocpt0/redo03.log