日期:2014-05-16  浏览次数:20337 次

Oracle基于Cancel的不完全恢复
实验时间:2011-10-14 环境:RED HAT4,Oracle 10.0.20

基于Cancel的不完全恢复适用场景:Recover时,所需的某个归档日志损坏,或主机断电,current状态的联机日志损坏。

一、环境准备
以SCOTT用户登录,新建表EMP1,切换日志,再新建表EMP2,主机断电,删除当前日志文件,模拟文件损坏。具体命令如下:
SQL> conn scott/oracle
Connected.
SQL> create table emp1 as select * from emp;

Table created.

SQL> conn / as sysdba
Connected.
SQL> alter system switch logfile;

System altered.
SQL> conn scott/oracle
Connected.
SQL> create table emp2 as select * from emp;

Table created.
SQL> conn / as sysdba
Connected.

确认日志的位置。
SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          5   52428800          1 NO  CURRENT                 916653 14-OCT-11
         2          1          4   52428800          1 YES ACTIVE                  915569 14-OCT-11
         3          1          3   52428800          1 YES INACTIVE                915566 14-OCT-11

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                                       IS_
---------- ------- ------- ------------------------ ---
         3         ONLINE  /home/oracle/oracle/product/oradata/orcl/redo03.log          NO
         2         ONLINE  /home/oracle/oracle/product/oradata/orcl/redo02.log          NO
         1         ONLINE  /home/oracle/oracle/product/oradata/orcl/redo01.log          NO     
        
SQL> shutdown abort
ORACLE instance shut down.
SQL> !rm -f /home/oracle/oracle/product/oradata/orcl/redo02.log

二、恢复步骤
1、尝试打开数据库
SQL> startup
ORACLE instance started.

Total System Global Area  130023424 bytes
Fixed Size                  1218100 bytes
Variable Size              671113