操作系统:Suse linux 9
数据库:oracle10gR2
存在的备份:原来数据库的全备份和控制文件的备份,并且原来的rman备份中没有用恢复目录,但是控制文件是自动备份的。
恢复如下:
1:首先在控制文件的备份中恢复spfile参数文件信息
oracle@linux:/free/oracle/oradata/orcl> rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on 星期一 11月 20 10:12:12 2006
www.ixdba.net
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
rman可以在没有任何数据库启动参数的情况下启动数据库到nomount状态,
默认启动的数据库名字为 DUMMY,
利用这个特性在原来备份的控制文件中恢复spfile参数文件。
RMAN>SET DBID=1132959697
executing command: SET DBID
RMAN> startup nomount
startup failed: ORA-01078: failure in processing system parameters
LRM-00109:could not open parameter file '/free/oracle/product/10.2.0/db_1/dbs/initorcl.ora'
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 1218268 bytes
Variable Size 54528292 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes
可以看到rman启动了一个默认的实例
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
此时,rman的配置都在rman默认的状态。
RMAN>
restore spfile from '/free/oracle/orabak/c-1132959697-20061119-00';
Starting restore at 20-11月-06
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=37 devtype=DISK
channel RA_DISK_1: autobackup found: /free/oracle/orabak/c-1132959697-20061119-00
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 20-11月-06
可以指定restore spfile文件到一个指定的地方, 如果没有指定,
默认恢复到$ORACLE_HOME/dbs下面。
RMAN>
RMAN> shutdown immediate
using target database control file instead of recovery catalog
Oracle instance shut down
RMAN> quit
Recovery Manager complete.
2:重新登陆rman进行控制文件的恢复
oracle@linux:~> rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on 星期一 11月 20 10:17:19 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup nomount
Oracle instance started
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 71305460 bytes
Database Buffers 92274688 bytes
Redo Buffers 2973696 bytes
有了参数文件,恢复成功了第一步,
可以看到,上面的实例就是从恢复的参数文件中启动的。
RMAN>
restore controlfile from '/free/oracle/orabak/c-1132959697-20061119-00';
Starting restore at 20-11月-06
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/free/oracle/oradata/orcl/control01.ctl
output filename=/free/oracle/oradata/orcl/control02.ctl
output filename=/free/oracle/oradata/orcl/control03.ctl
Finished restore at 20-11月-06
同spfile文件一样,可以恢复控制文件到一个指定的地方,
如果不指定,默认恢复到$ORACLE_BASE/oradata下面。
RMAN> shutdown immediate
Oracle instance shut down
RMAN> quit
Recovery Manager complete.
关闭数据库退出rman,然后启动数据库到mount状态。
3:恢复所有数据文件
oracle@linux:~> rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on 星期一 11月 20 10:18:26 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup mount
Oracle instance started
database mounted
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 71305460 bytes
Database Buffers 92274688 bytes
Redo Buffers 2973696 bytes
可以看到,控制文件恢复成功后,数据库可以启动到mount状态。
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/free/oracle/orabak/%F';
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
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/free/oracle/product/10.2.0/db_1/dbs/snapcf_orcl.f'; # default
rman配置信息是记录在控制文件中的,控制文件恢复成功后,
可以看到,rman的配置信息出来了,这样恢复就可以依据这个信息继续进行。
下面恢复数据文件
RMAN> restore database;
Starting restore at 20-11月-06
Starting implicit crosscheck backup at 20-11月-06
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 20-11月-06
Starting implicit crosscheck copy at 20-11月-06
using channel ORA_DISK_1
Finished implicit crosscheck copy at 20-11月-06
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /free/oracle/oradata/orcl/system01.dbf
restoring datafile 00002 to /free/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /free/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /free/oracle/oradata/orcl/users01.dbf
restoring datafile 00005 to /free/oracle/oradata/orcl/gaojfdb.dbf
channel ORA_DISK_1: reading from backup piece /free/oracle/orabak/full_ORCL_20061119_5
channel ORA_DISK_1: restore complete, elapsed time: 00:02:29
Finished restore at 20-11月