基于log序列号的不完全恢复

----基于log序列号的不完全恢复
[oracle@station strom_oradata]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jun 8 15:48:58 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> create table hr.strom (a number) tablespace users;
Table created.
SQL> alter system switch logfile;
System altered.
SQL> insert into hr.strom values(1);
1 row created.
SQL> alter system switch logfile;
System altered.
SQL> commit;
Commit complete.
SQL> host sleep 5                                                   ----停留5秒
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     50
Next log sequence to archive   52
Current log sequence           52                                   ----记住这个log sequence序号,以下要通过这个修复
SQL> host sleep 3
SQL> alter system switch logfile;
System altered.
SQL> insert into hr.strom values(2);
1 row created.
SQL> alter system switch logfile;
System altered.
SQL> commit;
Commit complete.
SQL> insert into hr.strom values(23);
1 row created.
SQL> alter system switch logfile;
System altered.
SQL> commit;
Commit complete.
SQL> drop table hr.strom;
Table dropped.
SQL> !
[oracle@station strom_oradata]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jun 8 15:54:42 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: ORCL (DBID=1312694260)
RMAN> shutdown immediate
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
RMAN> startup mount
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area     281018368 bytes
Fixed Size                     2020192 bytes
Variable Size                155192480 bytes
Database Buffers             121634816 bytes
Redo Buffers                   2170880 bytes
RMAN> run { set until sequence 53 thread 1;       
2> restore database;
3> recover database;
4> }
---注意:记得这里是取53,如果你的log sequence 是52,这里要往后加1。如果不加1的话hr用户下的strom表就没有数据了。因为52的序号是在create 表的情况记录的,不是在插入数据情况记录的。
executing command: SET until clause
Starting restore at 08-JUN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_7x4lym26_.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_7wnthzt6_.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_7wnthzp2_.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_7x4j6bxl_.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_7wntlh6m_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_06_08/o1_mf_nnnd0_STROM_FULL_0_BACKUP_7x4omg5o_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_06_08/o1_mf_nnnd0_STROM_FULL_0_BACKUP_7x4omg5o_.bkp tag=STROM_FULL_0_BACKUP
channel ORA_DISK_1: restore complete, elapsed time: 00:01:06
Finished restore at 08-JUN-12
Starting recover at 08-JUN-12
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 49 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_08/o1_mf_1_49_7x4op641_.arc
archive log thread 1 sequence 50 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_08/o1_mf_1_50_7x4otv4k_.arc
archive log thread 1 sequence 51 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_08/o1_mf_1_51_7x4ovy7j_.arc
archive log thread 1 sequence 52 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_08/o1_mf_1_52_7x4oylqr_.arc
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_08/o1_mf_1_49_7x4op641_.arc thread=1 sequence=49
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_08/o1_mf_1_50_7x4otv4k_.arc thread=1 sequence=50
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_08/o1_mf_1_51_7x4ovy7j_.arc thread=1 sequence=51
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_08/o1_mf_1_52_7x4oylqr_.arc thread=1 sequence=52
media recovery complete, elapsed time: 00:00:02
Finished recover at 08-JUN-12
RMAN> alter database open resetlogs;
database opened

RMAN> quit;

Recovery Manager complete.
[oracle@station strom_oradata]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jun 8 16:00:36 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> select * from hr.strom;
         A
----------
         1
总结:基于时间的不完全恢复和基于log序列号的不完全恢复
不完全恢复就是:并不是在归档重做日志中的所有事务都应用于数据库而使数据库完整。在恢复过程结束后,使用不完全恢复的数据库仍然丢失一些事务,这些事务在故障之前是在数据库中的。RMAN:两种方法完成不完全恢复:  
1.执行recover之前使用子句:Set until time或者set until sequence  
2.执行recover时使用子句Until time 或者 until sequence在完全恢复之前,在指定的时间点、一个重做日志序列或者一个变化号(SCN)停止。
用户管理不完全备份:使用RECOVER DATABASE命令与UNTIL TIME、UNTIL CHANGE或者UNTIL CANCEL子句。(其中与RMAN不同的是until cancel子句专门在随机点停止恢复过程)。  RMAN不完全恢复可以根据指定时间、重做日志序列或者变化号SNC来进行。完成不完全恢复使用recover database命令和until time、until SCN或者until sequence子句结合;

本文出自 “strom的博客” 博客,谢绝转载!

你可能感兴趣的:(oracle,System,number,序列号,的)