ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 基于时间的不完全恢复

基于时间的不完全恢复

原创 Linux操作系统 作者:atx2418 时间:2012-07-12 21:27:54 0 删除 编辑
---基于时间的不完全恢复

[oracle@station datafile]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sat Jun 9 17:11:44 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: ORCL (DBID=1312694260)

RMAN> list backup;

using target database control file instead of recovery catalog

RMAN> backup archivelog all delete all input;                                           ------ 备份默认目录下所有归档日志,并且删除这个目录下所有归档日志

Starting backup at 09-JUN-12
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=38 recid=37 stamp=785521285
input archive log thread=1 sequence=39 recid=38 stamp=785521355
input archive log thread=1 sequence=40 recid=39 stamp=785522322
channel ORA_DISK_1: starting piece 1 at 09-JUN-12
channel ORA_DISK_1: finished piece 1 at 09-JUN-12
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_06_09/o1_mf_annnn_TAG20120609T171231_7x7h20xb_.bkp tag=TAG20120609T171231 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_38_7x7d25qb_.arc recid=37 stamp=785521285
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_39_7x7d4cw3_.arc recid=38 stamp=785521355
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_40_7x7f2lc4_.arc recid=39 stamp=785522322
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=1 recid=40 stamp=785522710
input archive log thread=1 sequence=2 recid=41 stamp=785522833
input archive log thread=1 sequence=3 recid=42 stamp=785522881
input archive log thread=1 sequence=4 recid=43 stamp=785522924
input archive log thread=1 sequence=5 recid=44 stamp=785522959
input archive log thread=1 sequence=6 recid=45 stamp=785523017
input archive log thread=1 sequence=7 recid=46 stamp=785523040
input archive log thread=1 sequence=8 recid=47 stamp=785523055
input archive log thread=1 sequence=9 recid=48 stamp=785523413
channel ORA_DISK_1: starting piece 1 at 09-JUN-12
channel ORA_DISK_1: finished piece 1 at 09-JUN-12
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_06_09/o1_mf_annnn_TAG20120609T171231_7x7h233q_.bkp tag=TAG20120609T171231 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_1_7x7fgpof_.arc recid=40 stamp=785522710
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_2_7x7flk64_.arc recid=41 stamp=785522833
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_3_7x7fn16y_.arc recid=42 stamp=785522881
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_4_7x7fod5l_.arc recid=43 stamp=785522924
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_5_7x7fph2o_.arc recid=44 stamp=785522959
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_6_7x7fr97q_.arc recid=45 stamp=785523017
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_7_7x7fs08x_.arc recid=46 stamp=785523040
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_8_7x7fsh6x_.arc recid=47 stamp=785523055
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_9_7x7g4o20_.arc recid=48 stamp=785523413
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=1 recid=49 stamp=785524351
channel ORA_DISK_1: starting piece 1 at 09-JUN-12
channel ORA_DISK_1: finished piece 1 at 09-JUN-12
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_06_09/o1_mf_annnn_TAG20120609T171231_7x7h2594_.bkp tag=TAG20120609T171231 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_1_7x7h1z3f_.arc recid=49 stamp=785524351
Finished backup at 09-JUN-12


RMAN> backup tag 'strom_full_0_backup' incremental level 0 database plus archivelog;                 ------ 增量备份


Starting backup at 09-JUN-12
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=2 recid=50 stamp=785524470
channel ORA_DISK_1: starting piece 1 at 09-JUN-12
channel ORA_DISK_1: finished piece 1 at 09-JUN-12
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_06_09/o1_mf_annnn_STROM_FULL_0_BACKUP_7x7h5q8h_.bkp tag=STROM_FULL_0_BACKUP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 09-JUN-12

Starting backup at 09-JUN-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_7x4hyn9s_.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_7wnthzp2_.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_7wntlh6m_.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_7wnthzt6_.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_7x4cxo35_.dbf
channel ORA_DISK_1: starting piece 1 at 09-JUN-12
channel ORA_DISK_1: finished piece 1 at 09-JUN-12
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_06_09/o1_mf_nnnd0_STROM_FULL_0_BACKUP_7x7h5rj3_.bkp tag=STROM_FULL_0_BACKUP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 09-JUN-12
channel ORA_DISK_1: finished piece 1 at 09-JUN-12
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_06_09/o1_mf_ncsn0_STROM_FULL_0_BACKUP_7x7h7ton_.bkp tag=STROM_FULL_0_BACKUP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 09-JUN-12

Starting backup at 09-JUN-12
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=3 recid=51 stamp=785524539
channel ORA_DISK_1: starting piece 1 at 09-JUN-12
channel ORA_DISK_1: finished piece 1 at 09-JUN-12
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_06_09/o1_mf_annnn_STROM_FULL_0_BACKUP_7x7h7wv5_.bkp tag=STROM_FULL_0_BACKUP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 09-JUN-12

RMAN> quit


Recovery Manager complete.
[oracle@station datafile]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jun 9 17:16:19 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> commit;

Commit complete.

SQL> host sleep 5

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> drop table hr.strom;

Table dropped.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> !
[oracle@station datafile]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sat Jun 9 17:23:14 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: ORCL (DBID=1312694260, not open)

RMAN> run { sql "alter session set nls_date_format=''yyyy-mm-dd:hh24:mi:ss''";
2> set until time '2012-06-09:17:18:27';                             ----还原到这个时间点,2012-06-09:17:18:27时间是上面 sleep 5 后记录的时间 看时间用linux上的date命令
3> restore database;
4> recover database;
5> }

using target database control file instead of recovery catalog
sql statement: alter session set nls_date_format=''yyyy-mm-dd:hh24:mi:ss''

executing command: SET until clause

Starting restore at 09-JUN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 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_7x4hyn9s_.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_7x4cxo35_.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_09/o1_mf_nnnd0_STROM_FULL_0_BACKUP_7x7h5rj3_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_06_09/o1_mf_nnnd0_STROM_FULL_0_BACKUP_7x7h5rj3_.bkp tag=STROM_FULL_0_BACKUP
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 09-JUN-12

Starting recover at 09-JUN-12
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 3 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_3_7x7h7vqf_.arc
archive log thread 1 sequence 4 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_4_7x7hc0gs_.arc
archive log thread 1 sequence 5 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_5_7x7hgclh_.arc
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_3_7x7h7vqf_.arc thread=1 sequence=3
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_06_09/o1_mf_1_4_7x7hc0gs_.arc thread=1 sequence=4
media recovery complete, elapsed time: 00:00:02
Finished recover at 09-JUN-12

RMAN> alter database open resetlogs;       ----- 执行了resetlogs命令之后,数据库的操作是:将没归档的日志都归档;然后将联机日志组都置为新的,序号从0开始。

database opened


RMAN> quit


Recovery Manager complete.
[oracle@station datafile]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jun 9 17:29:43 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

SQL> conn /as sysdba
Connected.
SQL> select * from hr.strom;

         A
----------
         1

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13453302/viewspace-735341/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-07-12

  • 博文量
    9
  • 访问量
    3750