环境:
OS:Red Hat Linux As 5
DB:10.2.0.4
如何查看数据库能否恢复到某个时间点,这里指的是正常的不完全恢复(有备份,也有归档日志),当刚接手某个数据库,对环境还不了解,尤其是是否有备份,归档日志是否完成的情况下,通过下面的方法可以定位是否做恢复到某个时间点的恢复.举了例子,如恢复到'20120710 20:30:00',查看是否有完整的备份和归档日志.
1.查看最近resetlog的时间点
SQL> select to_char(resetlogs_time,'YYYY-MM-DD HH24:MI:SS') resetlogs_time from v$database
RESETLOGS_TIME
-----------------
2012-07-07 11:14:06
查看resetlog的时间点的目的是确认该时间点之后是否有备份.
2.检查备份集
RMAN> list backup summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
64 B F A DISK 2012-07-07 10:12:23 1 1 NO TAG20120707T101200
65 B F A DISK 2012-07-07 10:12:33 1 1 NO TAG20120707T101200
66 B F A DISK 2012-07-07 10:12:47 1 1 NO TAG20120707T101200
67 B F A DISK 2012-07-07 10:12:51 1 1 NO TAG20120707T101200
68 B F A DISK 2012-07-07 10:12:53 1 1 NO TAG20120707T101200
69 B F A DISK 2012-07-07 10:13:09 1 1 NO TAG20120707T101200
70 B F A DISK 2012-07-10 20:23:05 1 1 NO TAG20120710T202242
71 B F A DISK 2012-07-10 20:23:18 1 1 NO TAG20120710T202242
72 B F A DISK 2012-07-10 20:23:23 1 1 NO TAG20120710T202242
73 B F A DISK 2012-07-10 20:23:26 1 1 NO TAG20120710T202242
74 B F A DISK 2012-07-10 20:23:42 1 1 NO TAG20120710T202242
75 B F A DISK 2012-07-10 20:24:06 1 1 NO TAG20120710T202242
76 B F A DISK 2012-07-10 20:27:21 1 1 NO TAG20120710T202703
77 B F A DISK 2012-07-10 20:27:28 1 1 NO TAG20120710T202703
78 B F A DISK 2012-07-10 20:27:42 1 1 NO TAG20120710T202703
79 B F A DISK 2012-07-10 20:27:49 1 1 NO TAG20120710T202703
80 B F A DISK 2012-07-10 20:27:50 1 1 NO TAG20120710T202703
81 B F A DISK 2012-07-10 20:28:06 1 1 NO TAG20120710T202703
可以看到2012-07-07 11:14:06之后是有备份的,而且是全备(LV=F),状态为可用(S=A).若恢复到20120710 20:30:00,oracle会使用最近的备份集 TAG20120710T202703.
3.校验归档日志
RMAN> crosscheck archivelog all;
RMAN> delete noprompt expired archivelog all;
4.查看备份之后的归档日志是否完整
column recid format 99;
column name format a40;
column sequence# format 99;
column resetlogs_time format a17;
column first_time format a17;
select recid,
name,
sequence#,
to_char(resetlogs_time,'YYYYMMDD HH24:MI:SS') resetlogs_time,
to_char(first_time,'YYYYMMDD HH24:MI:SS') first_time
from v$archived_log t
where t.resetlogs_change# in (select resetlogs_change# from v$database)
order by sequence#
----------------------------------------------------------------------------------
RECID NAME SEQUENCE# RESETLOGS_TIME FIRST_TIME
32 2012_07_10/o1_mf_1_1_7zr6v4vv_.arc 1 20120707 11:14:06 20120707 11:14:06
33 2012_07_20/o1_mf_1_2_80lnk4gb_.arc 2 20120707 11:14:06 20120710 20:09:08
34 2012_07_20/o1_mf_1_2_90lnk6yb_.arc 3 20120707 11:14:06 20120710 21:10:01
从以上输出可以看出,恢复到时间点'20120710 20:30:00',需要用到的日志1和日志2,3是完整的,所以可以执行这个时间点的不完全恢复.或备份了归档日志后使用delete all input删除了归档日志,可以使用list backup查看备份的归档日志是否完整.
5.执行不完全恢复
RMAN>shutdown immediate
RMAN>startup mount
RMAN>run{
set until time "to_date('20120710 20:30:00','YYYYMMDD HH24:MI:SS')";
restore database;
recover database;
}
6.打开数据库
RMAN> alter database open resetlogs;
-- The End --
阅读(4576) | 评论(0) | 转发(0) |