Chinaunix首页 | 论坛 | 博客
  • 博客访问: 397499
  • 博文数量: 99
  • 博客积分: 5134
  • 博客等级: 大校
  • 技术积分: 1607
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-30 09:31
文章分类

全部博文(99)

文章存档

2011年(48)

2010年(40)

2009年(10)

2008年(1)

分类:

2009-12-15 11:14:40

数据库: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


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';

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文件到一个指定的地方,

RESTORE spfile TO '/tmp/autobackup_20001002.dbf' FROM AUTOBACKUP

如果没有指定,

默认恢复到$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';

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文件一样,可以恢复控制文件到一个指定的地方,

RESTORE CONTROLFILE TO '/tmp/autobackup_20001002.dbf' FROM AUTOBACKUP

如果不指定,默认恢复到$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-06

数据文件恢复完毕。

4:开始进行介质恢复

如果原来数据库的redo文件还保存完好,

那么复制redo文件到新的数据库,可以保证完全恢复数据。

RMAN> recover database;

Starting recover at 20-11-06

using channel ORA_DISK_1

starting media recovery


archive log thread 1 sequence 37 is already on disk as file /free/oracle/oradata/orcl/redo01.log

archive log thread 1 sequence 38 is already on disk as file /free/oracle/oradata/orcl/redo02.log

archive log filename=/free/oracle/oradata/orcl/redo01.log thread=1 sequence=37

archive log filename=/free/oracle/oradata/orcl/redo02.log thread=1 sequence=38

media recovery complete, elapsed time: 00:00:18

Finished recover at 20-11-06

 

可以看到rman仍然可以知道以前数据库中的redo file信息进行恢复。

 

由于是用的备份的控制文件恢复的数据库,

因此,oracle要同步数据库,所以必须resetlogs打开数据库。

RMAN> alter database open resetlogs;

database opened

RMAN>

 

成功恢复。

5:总结

1rman恢复数据库必须要有控制文件的完整备份,参数文件也默认备份到控制文件中。

2:利用rman全备份恢复数据到另外一台服务器上,新的数据库各种路径设置尽量要和原来数据库配置相同。

3rman 全备份时,默认是备份控制文件的,但是如果设置了控制文件自动备份,那么rman全备份将不再备份控制文件,因此在没有设置恢复目录的rman中,设置rman自动备份控制文件是很重要的。
阅读(954) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

todayboy2010-06-07 16:08:44

不错,学习了!!!!!