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

应用还原的控制文件进行不完全恢复

应用还原的控制文件进行不完全恢复
条件:归档日志文件完好(可能也会用到redo日志)

描述:有时当我们的数据库的在线日志丢失或损坏,我们可以恢复到最后一次归档的时间的时间点,而不使用redo log时进行不完全恢复,下面就是在没有redo log的情况下的一次不完全恢复实例。

backup datafile + backup controlfile + archivelog file    to recover database until time point

--备份数据文件
SQL> alter database begin backup;

Database altered.

SQL> host cp /u01/oracle/oradata/oemgc/*.dbf /u01/oracle/oradata/oemgc_bk

SQL> alter database end backup;--据说这个操作包含了归档操作

Database altered.

SQL> alter system switch logfile;--或是alter system archive log current;

System altered.


SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     2
Next log sequence to archive   4
Current log sequence           4

--备份控制文件
SQL> alter database backup controlfile to '/u01/oracle/oradata/ctr.ctl';

Database altered.

SQL> create table a1 as select * from dba_tables;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     2
Next log sequence to archive   5
Current log sequence           5

--查看当前时间为t1 = 2010-10-20 16:30:19
SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'YY
-------------------
2010-10-20 16:30:19


SQL> create table a3 as select * from dba_tables;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'YY
-------------------
2010-10-20 16:31:25

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     4
Next log sequence to archive   6
Current log sequence           6
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

--还原控制文件和数据文件
[oracle@DB1 oradata]$ cp ctr.ctl oemgc/control01.ctl
[oracle@DB1 oradata]$ cp ctr.ctl oemgc/control02.ctl
[oracle@DB1 oradata]$ cp ctr.ctl oemgc/control03.ctl
[oracle@DB1 oradata]$ cd oemgc_bk
[oracle@DB1 oemgc_bk]$ cp * ../oemgc

--删除redo log
[oracle@DB1 oemgc_bk]$ cd ../oemgc
[oracle@DB1 oemgc]rm *.log

--恢复数据库到t1时点
SQL> startup mount
ORACLE instance started.

Total System Global Area 289406976 bytes
Fixed Size                  1219016 bytes
Variable Size              71304760 bytes
Database Buffers          213909504