Starting Control File and SPFILE Autobackup at 20111019 22:17:45 piece handle=/db_backup/rman_backup/c-4067278754-20111019-00 comment=NONE Finished Control File and SPFILE Autobackup at 20111019 22:17:48
2)查看备份信息 RMAN> list backup;
List of Backup Sets ===================
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ----------------- 48 Full 1.10G DISK 00:00:57 20111019 22:17:33 BP Key: 47 Status: AVAILABLE Compressed: NO Tag: TAG20111019T221636 Piece Name: /oracle/ora10gR2/flash_recovery_area/ORA10G/backupset/2011_10_19/o1_mf_nnndf_TAG20111019T221636_79xpy532_.bkp List of Datafiles in backup set 48 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- ----------------- ---- 1 Full 6494715 20111019 22:16:36 /oracle/ora10gR2/oradata/ora10g/system01.dbf 2 Full 6494715 20111019 22:16:36 /oracle/ora10gR2/oradata/ora10g/undotbs01.dbf 3 Full 6494715 20111019 22:16:36 /oracle/ora10gR2/oradata/ora10g/sysaux01.dbf 4 Full 6494715 20111019 22:16:36 /oracle/ora10gR2/oradata/ora10g/tbs_local_01.dbf 5 Full 6494715 20111019 22:16:36 /home/oracle/tbs_sec_d_01.dbf 6 Full 6494715 20111019 22:16:36 /oracle/ora10gR2/oradata/ora10g/users.dbf 7 Full 6494715 20111019 22:16:36 /oracle/ora10gR2/oradata/ora10g/undotbs_guarantee.dbf 8 Full 6494715 20111019 22:16:36 /oracle/ora10gR2/oradata/ora10g/tbs01.dbf 9 Full 6494715 20111019 22:16:36 /oracle/ora10gR2/oradata/ora10g/tbs_secooler_01.dbf 10 Full 6494715 20111019 22:16:36 /oracle/ora10gR2/oradata/ora10g/tbs_perf_01.dbf 16 Full 6494715 20111019 22:16:36 /u01/app/oracle/oradata/PROD/disk1/INDX_01.dbf 17 Full 6494715 20111019 22:16:36 /u01/app/oracle/oradata/PROD/disk1/TOOLS_01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ----------------- 49 Full 1.02M DISK 00:00:01 20111019 22:17:43 BP Key: 48 Status: AVAILABLE Compressed: NO Tag: TAG20111019T221636 Piece Name: /oracle/ora10gR2/flash_recovery_area/ORA10G/backupset/2011_10_19/o1_mf_nnndf_TAG20111019T221636_79xq067w_.bkp List of Datafiles in backup set 49 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- ----------------- ---- 11 Full 6494738 20111019 22:17:42 /u01/app/oracle/oradata/PROD/disk1/DATA01_01.dbf 12 Full 6494738 20111019 22:17:42 /u01/app/oracle/oradata/PROD/disk2/DATA01_02.dbf 13 Full 6494738 20111019 22:17:42 /u01/app/oracle/oradata/PROD/disk3/DATA01_03.dbf 14 Full 6494738 20111019 22:17:42 /u01/app/oracle/oradata/PROD/disk4/DATA01_04.dbf 15 Full 6494738 20111019 22:17:42 /u01/app/oracle/oradata/PROD/disk5/DATA01_05.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ----------------- 50 Full 6.83M DISK 00:00:00 20111019 22:17:45 BP Key: 49 Status: AVAILABLE Compressed: NO Tag: TAG20111019T221745 Piece Name: /db_backup/rman_backup/c-4067278754-20111019-00 Control File Included: Ckp SCN: 6494743 Ckp time: 20111019 22:17:45 SPFILE Included: Modification time: 20111019 22:11:53
3.模拟数据库故障——表的误TRUNCATE 1)连接到数据库的sec用户 ora10g@secdb /home/oracle$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Oct 19 22:20:57 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options
sys@ora10g> conn sec/oracle_1 Connected.
2)查看T表中的数据行数 sec@ora10g> select count(*) from t;
COUNT(*) ---------- 1000
此时T表中包含1000条数据。
3)查看当前时间,以便后续使用RMAN进行恢复 sec@ora10g> alter session set nls_date_format='yyyy-mm-dd hh34:mi:ss';
Total System Global Area 536870912 bytes Fixed Size 1220460 bytes Variable Size 318767252 bytes Database Buffers 209715200 bytes Redo Buffers 7168000 bytes Database mounted.
2)使用RMAN脚本恢复数据库到指定时间点 (1)恢复脚本如下 run { allocate channel c1 type disk; allocate channel c2 type disk; sql 'alter session set nls_date_format="yyyy-mm-dd hh34:mi:ss"'; set until time = '2011-10-19 22:21:38'; restore database; recover database; alter database open resetlogs;}
(2)恢复过程记录 RMAN> run { 2> allocate channel c1 type disk; 3> allocate channel c2 type disk; 4> sql 'alter session set nls_date_format="yyyy-mm-dd hh34:mi:ss"'; 5> set until time = '2011-10-19 22:21:38'; 6> restore database; 7> recover database; 8> alter database open resetlogs;}
using target database control file instead of recovery catalog allocated channel: c1 channel c1: sid=211 devtype=DISK