Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2381323
  • 博文数量: 384
  • 博客积分: 10193
  • 博客等级: 上将
  • 技术积分: 3785
  • 用 户 组: 普通用户
  • 注册时间: 2005-06-09 18:02
文章分类

全部博文(384)

文章存档

2011年(10)

2010年(29)

2009年(39)

2008年(36)

2007年(43)

2006年(198)

2005年(29)

分类: Oracle

2009-01-10 10:54:11

用drbd模拟盘阵镜像进行oracle备份测试(四):数据库恢复测试
       作者:blue_stone(blue_stone@xinhuanet.com)
       转载请注明出处: http://bluestone.cublog.cn

一 单个数据文件丢失的恢复

在oem2上将以数据文件置为offline, 然后删除.

[oracle@oem2 o102db1data]$ sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Fri Dec 19 03:21:40 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Enter user-name: / as sysdba

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options                   

SQL> alter database datafile '/u01/app/oracle/oradata/o102db1/testbk01.dbf' offline;

Database altered.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

恢复该数据文件

[oracle@oem2 o102db1data]$ rman target / catalog rman/rman@rman                         

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Dec 19 03:22:16 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: O102DB1 (DBID=2838976858)
connected to recovery catalog database                 

RMAN> restore datafile 'alter database datafile '/u0                                                   
'/u01/app/oracle/oradata/o102db1/testbk01.dbf';

Starting restore at 19-DEC-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00007 to /u01/app/oracle/oradata/o102db1/testbk01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/dbO102DB1_9_1_673844707
channel ORA_DISK_1: restored backup piece 1                                                 
piece handle=/u01/app/oracle/backup/dbO102DB1_9_1_673844707 tag=TAG20081219T030506          
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15                                
Finished restore at 19-DEC-08                                                               

RMAN> recover datafile '/u01/app/oracle/oradata/o102db1                 
testbk01.dbf';                                                          

Starting recover at 19-DEC-08
using channel ORA_DISK_1     
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/19/2008 03:26:08          
RMAN-06094: datafile 7 must be restored                                

RMAN> restore datafile 7;

Starting restore at 19-DEC-08
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 00007 to /u01/app/oracle/oradata/o102db1/testbk01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/dbO102DB1_9_1_673844707
channel ORA_DISK_1: restored backup piece 1                                                 
piece handle=/u01/app/oracle/backup/dbO102DB1_9_1_673844707 tag=TAG20081219T030506          
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16                                
Finished restore at 19-DEC-08                                                               

RMAN>  recover datafile '/u01/app/oracle/oradata/o102db1/testbk01.dbf';

Starting recover at 19-DEC-08
using channel ORA_DISK_1     
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00007: /u01/app/oracle/oradata/o102db1/testbk01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/dbO102DB1_11_1_673845470
channel ORA_DISK_1: restored backup piece 1                                                  
piece handle=/u01/app/oracle/backup/dbO102DB1_11_1_673845470 tag=TAG20081219T031747          
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04                                 

starting media recovery
media recovery complete, elapsed time: 00:00:05

Finished recover at 19-DEC-08

RMAN> sql 'alter database datafile 7 online';

sql statement: alter database datafile 7 online

RMAN> shutdown immediate

database closed
database dismounted
Oracle instance shut down

RMAN> exit


Recovery Manager complete.

二 控制文件丢失情况下的恢复

使用操作系统命令删除所有控制文件, 然后在rman中进行恢复

[oracle@oem2 o102db1data]$ rman target / catalog rman/rman@rman

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Dec 19 03:29:00 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database (not started)
connected to recovery catalog database    

RMAN> startup nomount

Oracle instance started

Total System Global Area     285212672 bytes

Fixed Size                     1218992 bytes
Variable Size                 75499088 bytes
Database Buffers             205520896 bytes
Redo Buffers                   2973696 bytes

RMAN> restore controlfile;

Starting restore at 19-DEC-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: copied control file copy
input filename=/u03/control_backup          
output filename=/u01/app/oracle/oradata/o102db1/control01.ctl
output filename=/u01/app/oracle/oradata/o102db1/control02.ctl
output filename=/u01/app/oracle/oradata/o102db1/control03.ctl
Finished restore at 19-DEC-08                                

RMAN> exit


Recovery Manager complete.
[oracle@oem2 o102db1data]$ sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Fri Dec 19 03:30:59 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Enter user-name: / as sysdba

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options                   

SQL> alter database mount;

Database altered.

SQL> alter database open;
alter database open      
*                        
ERROR at line 1:         
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> recover database using backup controlfile;
ORA-00279: change 636432 generated at 12/19/2008 01:16:50 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/oradata/o102db1/arch/1_17_654397857.dbf
ORA-00280: change 636432 for thread 1 is in sequence #17                       


Specify log: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log
'/u01/app/oracle/oradata/o102db1/arch/1_17_654397857.dbf'
ORA-27037: unable to obtain file status                  
Linux Error: 2: No such file or directory                
Additional information: 3                                


ORA-00308: cannot open archived log
'/u01/app/oracle/oradata/o102db1/arch/1_17_654397857.dbf'
ORA-27037: unable to obtain file status                  
Linux Error: 2: No such file or directory                
Additional information: 3                                


SQL> alter database open noresetlogs;
alter database open noresetlogs
*
ERROR at line 1:
ORA-01588: must use RESETLOGS option for database open


SQL> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              75499088 bytes
Database Buffers          205520896 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@oem2 o102db1data]$

三 未做的恢复测试

  在这次试验中, 我并没有做system表空间数据文件丢失的测试, 单个归档日志的恢复测试, 全数据库的不完整恢复测试等, 如果用做生产数据库的恢复测试, 还需要增加这几个测试. 这是因为我们关注的焦点是在别的机器上备份的数据库可否在本机上被恢复, 在mount状态下备份的数据文件和归档日志文件在整个备份过程中都未发生过更改, 而控制文件则发生了更改.
阅读(2089) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~