1、恢复之前必须知道目标数据库的DBID,多种方式可查。
(1)、语句查询
SQL> select dbid from v$database; DBID ---------- 1299908003
(2)进入RMAN时,有提示。
[oracle@edrsr9p1 ~]$ rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Sun Nov 11 11:28:22 2012 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: ORCL (DBID=1299908003)
2、演示环境。
SQL> insert into stu values(4, 'dd');
SQL> select * from stu; ID NAME ---------- -------------------- 4 dd 3 cc 1 aa 2 bb
3、删掉全部控制文件,启动数据库(NOMOUNT状态)。
[oracle@edrsr9p1 ~]$ rm -f /u01/app/oracle/oradata/orcl/control*;
SQL> startup; ORA-32004: obsolete and/or deprecated parameter(s) specified ORACLE instance started. Total System Global Area 285212672 bytes Fixed Size 1218992 bytes Variable Size 134219344 bytes Database Buffers 146800640 bytes Redo Buffers 2973696 bytes ORA-00205: error in identifying control file, check alert log for more info
4、恢复控制文件。
RMAN> set dbid = 1299908003 executing command: SET DBID
先前都是在nocatalog进行,信息都保存在控制文件,丢失相当于配置丢失,配置都恢复默认值。
RMAN> show all; using target database control file instead of recovery catalog 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 OFF; # default 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 ENCRYPTION FOR DATABASE OFF; # default CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
恢复时候不能直接restore controlfile from autobackup,因为自动备份的设置丢了,此时无法配置CONTROLFILE AUTOBACKUP。选择显示指定备份集方式恢复控制文件。
RMAN> restore controlfile from '/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_11/o1_mf_s_799069140_89y7gp75_.bkp'; Starting restore at 2012-11-11 12:18:44 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=151 devtype=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 output filename=/u01/app/oracle/oradata/orcl/control01.ctl output filename=/u01/app/oracle/oradata/orcl/control02.ctl output filename=/u01/app/oracle/oradata/orcl/control03.ctl Finished restore at 2012-11-11 12:18:45
数据库启起来。
RMAN> alter database mount; database mounted released channel: ORA_DISK_1
只是丢失控制文件,数据文件还在,不需要修复,只需要执行recover,应用之后生成的重做日志。
RMAN> recover database; Starting recover at 2012-11-11 12:21:23 Starting implicit crosscheck backup at 2012-11-11 12:21:23 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=151 devtype=DISK Crosschecked 2 objects Finished implicit crosscheck backup at 2012-11-11 12:21:24 Starting implicit crosscheck copy at 2012-11-11 12:21:24 using channel ORA_DISK_1 Crosschecked 2 objects Finished implicit crosscheck copy at 2012-11-11 12:21:24 searching for all files in the recovery area cataloging files... cataloging done List of Cataloged Files ======================= File Name: /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_11/o1_mf_s_799069140_89y7gp75_.bkp using channel ORA_DISK_1 starting media recovery archive log thread 1 sequence 3 is already on disk as file /u01/app/oracle/oradata/orcl/redo03.log archive log filename=/u01/app/oracle/oradata/orcl/redo03.log thread=1 sequence=3 media recovery complete, elapsed time: 00:00:03 Finished recover at 2012-11-11 12:21:28
打开数据库,通过备份的控制文件恢复,必须指定resetlogs。
RMAN> alter database open resetlogs; database opened
5、检查数据。
SQL> select * from stu; ID NAME ---------- -------------------- 4 dd 3 cc 1 aa 2 bb