|
若使用了CONFIGURE CONTROLFILE AUTOBACKUP ON 选项,则还可以更简单
RMAN会根据DBID来找到自动备份控制文件(CONTROLFILE AUTOBACKUP)备份集来进行恢复:
1、
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON; -- AUTOBACKUP 是 ON 的
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'F:\ORACLE10\DATABASE\SNCFORACLE10.ORA'; # default
2、做一个全库备份
F:\ORACLE10\BIN>rman target /
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.
connected to target database: ORACLE10 (DBID=2255754647)
RMAN> run
2> {allocate channel d1 type disk;
3> backup full database
4> include current controlfile
5> format 'D:\ORACLE\rmanbak\db_%d_%s_%p_%t_%T';
6> release channel d1;
7> }
using target database controlfile instead of recovery catalog
allocated channel: d1
channel d1: sid=159 devtype=DISK
Starting backup at 2004-07-18 23:57:44
channel d1: starting full datafile backupset
channel d1: specifying datafile(s) in backupset
input datafile fno=00001 name=F:\ORADATA\ORACLE10\SYSTEM01.DBF
input datafile fno=00003 name=F:\ORADATA\ORACLE10\SYSAUX01.DBF
input datafile fno=00005 name=F:\ORADATA\ORACLE10\EXAMPLE01.DBF
input datafile fno=00002 name=F:\ORADATA\ORACLE10\UNDOTBS01.DBF
input datafile fno=00006 name=F:\ORADATA\ORACLE10\DEL_TS01.DBF
channel d1: starting piece 1 at 2004-07-18 23:57:44
channel d1: finished piece 1 at 2004-07-18 23:58:40
piece handle=D:\ORACLE\RMANBAK\DB_ORACLE10_37_1_531878264_20040718 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:56
channel d1: starting full datafile backupset
channel d1: specifying datafile(s) in backupset
including current controlfile in backupset
channel d1: starting piece 1 at 2004-07-18 23:58:40
channel d1: finished piece 1 at 2004-07-18 23:58:43
piece handle=D:\ORACLE\RMANBAK\DB_ORACLE10_38_1_531878320_20040718 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:03
Finished backup at 2004-07-18 23:58:43
Starting Control File and SPFILE Autobackup at 2004-07-18 23:58:43
piece handle=C:\WINNT\SYSTEM32\C-2255754647-20040718-01 comment=NONE
Finished Control File and SPFILE Autobackup at 2004-07-18 23:58:46
released channel: d1
RMAN> EXIT
Recovery Manager complete.
3、关闭数据库,删除数据文件、控制文件
F:\ORACLE10\BIN>sqlplus
SQL*Plus: Release 10.1.0.2.0 - Production on ??? 7? 18 23:59:27 2004
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Enter user-name: / AS SYSDBA
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> EXIT
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
4、启动数据库(NOT MOUNTED状态)
F:\ORACLE10\BIN>sqlplus
SQL*Plus: Release 10.1.0.2.0 - Production on ??? 7? 19 00:05:57 2004
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Enter user-name: / AS SYSDBA
Connected to an idle instance.
SQL> STARTUP NOMOUNT;
ORACLE instance started.
Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145750508 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
SQL> EXIT
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
5、使用RMAN来恢复
F:\ORACLE10\BIN>rman target /
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.
connected to target database: oracle10 (not mounted)
RMAN> set dbid 2255754647; --- 设置DBID是关键
executing command: SET DBID
RMAN> run
2> {allocate channel d1 type disk;
3> restore controlfile from autobackup;
4> alter database mount;
5> restore database;
6> recover database;
7> alter database open resetlogs;
8> release channel d1;
9> }
using target database controlfile instead of recovery catalog
allocated channel: d1
channel d1: sid=159 devtype=DISK
Starting restore at 2004-07-19 00:20:24
channel d1: looking for autobackup on day: 20040719
channel d1: looking for autobackup on day: 20040718
channel d1: autobackup found: c-2255754647-20040718-01 --找到AUTOBACKUP的备份集
channel d1: controlfile restore from autobackup complete
output filename=F:\ORADATA\ORACLE10\CONTROL01.CTL
output filename=F:\ORADATA\ORACLE10\CONTROL02.CTL
output filename=F:\ORADATA\ORACLE10\CONTROL03.CTL
Finished restore at 2004-07-19 00:20:29
database mounted
Starting restore at 2004-07-19 00:20:33
channel d1: starting datafile backupset restore
channel d1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to F:\ORADATA\ORACLE10\SYSTEM01.DBF
restoring datafile 00002 to F:\ORADATA\ORACLE10\UNDOTBS01.DBF
restoring datafile 00003 to F:\ORADATA\ORACLE10\SYSAUX01.DBF
restoring datafile 00005 to F:\ORADATA\ORACLE10\EXAMPLE01.DBF
restoring datafile 00006 to F:\ORADATA\ORACLE10\DEL_TS01.DBF
channel d1: restored backup piece 1
piece handle=D:\ORACLE\RMANBAK\DB_ORACLE10_37_1_531878264_20040718 tag=TAG20040718T235744
channel d1: restore complete
Finished restore at 2004-07-19 00:21:50
Starting recover at 2004-07-19 00:21:50
starting media recovery
unable to find archive log
archive log thread=1 sequence=1
released channel: d1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/19/2004 00:21:53
RMAN-06054: media recovery requesting unknown log: thread 1 seq 1 lowscn 1823201 --需要在线日志
RMAN> alter database open resetlogs;
database opened
RMAN>
此实验是在本机上操作的,若是不同机器(RMAN与目标数据库不同机器),会不会也有此结果?
RMAN是如何找到自动备份控制见文件的备份集? |
|