利用rman做数据文件丢失的恢复实验

利用rman做数据文件丢失的恢复实验
1.首先备份全库  实验环境 windows xp+oracle 9.2.0.1
C:\Documents and Settings\paulyi>rman target /

恢复管理器: 版本9.2.0.1.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

连接到目标数据库: TEST (DBID=1964268543)

RMAN> backup full database;

启动 backup 于 23-9月 -08
正在使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=13 devtype=DISK
通道 ORA_DISK_1: 正在启动 full 数据文件备份集
通道 ORA_DISK_1: 正在指定备份集中的数据文件
输入数据文件 fno=00001 name=D:\ORACLE\ORADATA\TEST\SYSTEM01.DBF
输入数据文件 fno=00002 name=D:\ORACLE\ORADATA\TEST\UNDOTBS01.DBF
输入数据文件 fno=00005 name=D:\ORACLE\ORADATA\TEST\EXAMPLE01.DBF
输入数据文件 fno=00010 name=D:\ORACLE\ORADATA\TEST\XDB01.DBF
输入数据文件 fno=00006 name=D:\ORACLE\ORADATA\TEST\INDX01.DBF
输入数据文件 fno=00009 name=D:\ORACLE\ORADATA\TEST\USERS01.DBF
输入数据文件 fno=00003 name=D:\ORACLE\ORADATA\TEST\CWMLITE01.DBF
输入数据文件 fno=00004 name=D:\ORACLE\ORADATA\TEST\DRSYS01.DBF
输入数据文件 fno=00007 name=D:\ORACLE\ORADATA\TEST\ODM01.DBF
输入数据文件 fno=00008 name=D:\ORACLE\ORADATA\TEST\TOOLS01.DBF
通道 ORA_DISK_1: 正在启动段 1 于 23-9月 -08
通道 ORA_DISK_1: 已完成段 1 于 23-9月 -08
段 handle=D:\BACKUP\BACKUP_0IJRABD7_1_1 comment=NONE
通道 ORA_DISK_1: 备份集已完成, 经过时间:00:01:06
完成 backup 于 23-9月 -08

启动 Control File and SPFILE Autobackup 于 23-9月 -08
段 handle=D:\BACKUP\C-1964268543-20080923-07 comment=NONE
完成 Control File and SPFILE Autobackup 于 23-9月 -08

RMAN>exit


SQL> select tablespace_name from user_tables where table_name='TEST';

TABLESPACE_NAME
------------------------------
TOOLS
SQL>select count(*) from test;
    count(*)
     236096
    
SQL> insert into test select * from test;    --产生数据

已创建236096行。

SQL> /

已创建472192行。

SQL> /

已创建944384行。

SQL> alter system switch logfile;

系统已更改。

SQL> select count(*) from test;

  COUNT(*)
----------
   1888768 


这个时候从操作系统删除数据文件tools01.dbf

下面利用rman在数据库mount的状态来恢复

SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> exit
从Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production中断开

C:\Documents and Settings\paulyi>d:

D:\>cd oracle\oradata\test

D:\oracle\oradata\test>dir
 驱动器 D 中的卷是 software
 卷的序列号是 3C2B-605D

 D:\oracle\oradata\test 的目录

2008-09-23  10:50   

D:\oracle\oradata\test>del TOOLS01.DBF

D:\oracle\oradata\test>dir
 驱动器 D 中的卷是 software
 卷的序列号是 3C2B-605D

 D:\oracle\oradata\test 的目录

2008-09-23  11:33   

D:\oracle\oradata\test>sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.1.0 - Production on 星期二 9月 23 11:33:40 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

已连接到空闲例程。

SQL> startup;
ORACLE 例程已经启动。

Total System Global Area  496049552 bytes
Fixed Size                   454032 bytes
Variable Size             201326592 bytes
Database Buffers          293601280 bytes
Redo Buffers                 667648 bytes
数据库装载完毕。
ORA-01157: 无法标识/锁定数据文件 8 - 请参阅 DBWR 跟踪文件
ORA-01110: 数据文件 8: 'D:\ORACLE\ORADATA\TEST\TOOLS01.DBF'    --数据库启动报错,找不到数据文件


SQL>

SQL> exit
从Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production中断开

D:\oracle\oradata\test>rman target /

恢复管理器: 版本9.2.0.1.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

连接到目标数据库: TEST (DBID=1964268543)

RMAN> restore datafile 8;

启动 restore 于 23-9月 -08

正在使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=13 devtype=DISK
通道 ORA_DISK_1: 正在开始恢复数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集恢复的数据文件
正将数据文件00008恢复到D:\ORACLE\ORADATA\TEST\TOOLS01.DBF
通道 ORA_DISK_1: 已恢复备份段 1
段 handle=D:\BACKUP\BACKUP_0IJRABD7_1_1 tag=TAG20080923T112526 params=NULL
通道 ORA_DISK_1: 恢复完成
完成 restore 于 23-9月 -08

RMAN> recover datafile 8;

启动 recover 于 23-9月 -08
使用通道 ORA_DISK_1

正在开始介质的恢复
完成介质的恢复

完成 recover 于 23-9月 -08

RMAN> alter database open;

数据库已打开

RMAN> exit


恢复管理器完成。

D:\oracle\oradata\test>sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.1.0 - Production on 星期二 9月 23 11:37:22 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


连接到:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SQL> select count(*) from test;

  COUNT(*)
----------
   1888768

SQL>

--数据没丢失 恢复成功

利用rman在open状态下的恢复

D:\oracle\oradata\test>sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.1.0 - Production on 星期二 9月 23 11:40:16 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


连接到:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> exit
从Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production中断开

D:\oracle\oradata\test>del TOOLS01.DBF

D:\oracle\oradata\test>sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.1.0 - Production on 星期二 9月 23 11:40:43 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

已连接到空闲例程。

SQL> startup;
ORACLE 例程已经启动。

Total System Global Area  496049552 bytes
Fixed Size                   454032 bytes
Variable Size             201326592 bytes
Database Buffers          293601280 bytes
Redo Buffers                 667648 bytes
数据库装载完毕。
ORA-01157: 无法标识/锁定数据文件 8 - 请参阅 DBWR 跟踪文件
ORA-01110: 数据文件 8: 'D:\ORACLE\ORADATA\TEST\TOOLS01.DBF'


SQL> alter database datafile 'D:\ORACLE\ORADATA\TEST\TOOLS01.DBF' offline;

数据库已更改。

SQL> alter database open;

数据库已更改。

SQL> exit
从Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production中断开

D:\oracle\oradata\test>rman target /

恢复管理器: 版本9.2.0.1.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

连接到目标数据库: TEST (DBID=1964268543)

RMAN> restore datafile 8;

启动 restore 于 23-9月 -08

正在使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=15 devtype=DISK
通道 ORA_DISK_1: 正在开始恢复数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集恢复的数据文件
正将数据文件00008恢复到D:\ORACLE\ORADATA\TEST\TOOLS01.DBF
通道 ORA_DISK_1: 已恢复备份段 1
段 handle=D:\BACKUP\BACKUP_0IJRABD7_1_1 tag=TAG20080923T112526 params=NULL
通道 ORA_DISK_1: 恢复完成
完成 restore 于 23-9月 -08

RMAN> recover datafile 8;

启动 recover 于 23-9月 -08
使用通道 ORA_DISK_1

正在开始介质的恢复
完成介质的恢复

完成 recover 于 23-9月 -08

RMAN> exit


恢复管理器完成。

D:\oracle\oradata\test>sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.1.0 - Production on 星期二 9月 23 11:42:47 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


连接到:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SQL> alter database datafile 'D:\ORACLE\ORADATA\TEST\TOOLS01.DBF' online;

数据库已更改。

SQL> select count(*) from test;

  COUNT(*)
----------
   1888768

SQL>

--也恢复成功

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7199859/viewspace-462672/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7199859/viewspace-462672/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值