原来每次恢复数据库都是要求恢复到数据库出现问题的时候,但是最近由于需求,需要把数据恢复到一个时间点,因为这以后的时间是测试的,为了保证数据的正确,需要把数据恢复到一个时间点,备份过程简单说一下
1、 我开始先在一个用户下创建一个表,插入了10w的数据,然后备份数据库
2、 这里用一个简单的脚本备份测试的
C:\Documents and Settings\zhangli>rman
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.
RMAN> connect target /
connected to target database: ORCL (DBID=1132028839)
RMAN> connect catalog rman/rman
connected to recovery catalog database
RMAN> list incarnation of database;
updating recovery catalog with new database incarnation
starting full resync of recovery catalog
full resync complete
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 8 ORCL 1132028839 PARENT 1 09-3月 -04
1 2 ORCL 1132028839 PARENT 318842 19-10月-06
1 66 ORCL 1132028839 CURRENT 342200 19-10月-06
RMAN> create script dbbackup{
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> backup database;
5> }
created script dbbackup
RMAN> run {
2> execute script dbbackup;
3> }
ok备份成功
开始恢复
RMAN> sql 'alter session set nls_date_format="dd mm yyyy hh24:mi:ss"';
using target database controlfile instead of recovery catalog
sql statement: alter session set nls_date_format="dd mm yyyy hh24:mi:ss"
RMAN> run{
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> set until time '19 10 2006 20:30:00';
5> restore database;
6> recover database;
7> sql 'alter database open resetlog';
8> release channel c1;
9> release channel c2;
10> }
allocated channel: c1
channel c1: sid=159 devtype=DISK
allocated channel: c2
channel c2: sid=158 devtype=DISK
executing command: SET until clause
Starting restore at 19-10月-06
channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00006 to G:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\RMAN_TS
channel c2: starting datafile backupset restore
channel c2: specifying datafile(s) to restore from backup set
restoring datafile 00002 to G:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\UNDOTBS01.DBF
restoring datafile 00003 to G:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\SYSAUX01.DBF
channel c1: restored backup piece 1
piece handle=G:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2006_10
_19\O1_MF_NNNDF_TAG20061019T153323_2MGBLXY8_.BKP tag=TAG20061019T153323
channel c1: restore complete
channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to G:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\SYSTEM01.DBF
restoring datafile 00004 to G:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\USERS01.DBF
channel c2: restored backup piece 1
piece handle=G:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2006_10
_19\O1_MF_NNNDF_TAG20061019T153323_2MGBLDD6_.BKP tag=TAG20061019T153323
channel c2: restore complete
channel c1: restored backup piece 1
piece handle=G:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2006_10
_19\O1_MF_NNNDF_TAG20061019T153323_2MGBL5WS_.BKP tag=TAG20061019T153323
channel c1: restore complete
Finished restore at 19-10月-06
Starting recover at 19-10月-06
starting media recovery
archive log thread 1 sequence 8 is already on disk as file G:\ORACLE\PRODUCT\10.
1.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2006_10_19\O1_MF_1_8_2MGBNNDP_.ARC
archive log thread 1 sequence 9 is already on disk as file G:\ORACLE\PRODUCT\10.
1.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2006_10_19\O1_MF_1_9_2MGFTK5C_.ARC
archive log thread 1 sequence 10 is already on disk as file G:\ORACLE\PRODUCT\10
.1.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2006_10_19\O1_MF_1_10_2MGM15J3_.ARC
archive log thread 1 sequence 11 is already on disk as file G:\ORACLE\PRODUCT\10
.1.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2006_10_19\O1_MF_1_11_2MGRZD8S_.ARC
archive log thread 1 sequence 12 is already on disk as file G:\ORACLE\PRODUCT\10
.1.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2006_10_19\O1_MF_1_12_2MGW5Z7B_.ARC
archive log filename=G:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELO
G\2006_10_19\O1_MF_1_8_2MGBNNDP_.ARC thread=1 sequence=8
archive log filename=G:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELO
G\2006_10_19\O1_MF_1_9_2MGFTK5C_.ARC thread=1 sequence=9
archive log filename=G:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELO
G\2006_10_19\O1_MF_1_10_2MGM15J3_.ARC thread=1 sequence=10
archive log filename=G:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELO
G\2006_10_19\O1_MF_1_11_2MGRZD8S_.ARC thread=1 sequence=11
archive log filename=G:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELO
G\2006_10_19\O1_MF_1_12_2MGW5Z7B_.ARC thread=1 sequence=12
media recovery complete
Finished recover at 19-10月-06
sql statement: alter database open resetlog
released channel: c1
released channel: c2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 10/19/2006 21:04:03
RMAN-11003: failure during parse/execution of SQL statement: alter database open
resetlog
ORA-02288: invalid OPEN mode
哦,脚本有点错误,还是手工打开数据库吧,
sql>alter database open;
Database altered.
ok,恢复成功,可以在user_tables里查看最后的时间,就可以判断最后恢复的时间了,呵呵
阅读(2173) | 评论(1) | 转发(0) |