当前所在位置:珠峰网资料 >> 计算机 >> Oracle认证 >> 正文
RMAN之数据文件的恢复详解
发布时间:2011/11/16 10:32:41 来源:城市学习网 编辑:ziteng
  Oracle数据库REAN恢复之数据文件的恢复是本文我们主要要介绍的内容,我们知道,除了system表空间的数据文件(mount)之外,其它数据文件可以在open(mount也可以)状态下恢复。open状态下恢复数据文件可以减少数据库停用的时间,所以应该在open状态下恢复这些数据文件。
  示例一:数据文件被误删除
  1.[oracle@localhost ~]$  rm $ORACLE_BASE/product/10.2.0/oradatabak/example01.dbf;   SQL> select file#,error from v$recover_file;
  2.FILE# ERROR    ---------- ----------------------------------------
  3.5 FILE NOT FOUND   SQL> select file#,name from v$datafile where file#=5;
  4. FILE# NAME    ---------- -----------------------------------------
  5. 5 /oracle/10g/oracle/product/10.2.0/oradatabak/example01.dbf    --恢复数据文件
  6. RMAN> run {    startup force mount;
  7.sql 'alter database datafile 5 offline';   sql 'alter database open';
  8.restore datafile 5;    recover datafile 5;
  9.sql 'alter database datafile 5 online';    8> }
  示例二:数据文件所在磁盘出现损坏
  1. [oracle@localhost ~]$  rm $ORACLE_BASE/product/10.2.0/oradatabak/example01.dbf;
  2. SQL> select file#,error from v$recover_file;
  3. FILE# ERROR
  4. ---------- ---------------------------------------------------
  5.  5 FILE NOT FOUND
  6. SQL> select file#,name from v$datafile where file#=5;
  7. FILE# NAME
  8. ---------- ----------------------------------------------------
  9. 5 /oracle/10g/oracle/product/10.2.0/oradatabak/example01.dbf
  10. --恢复数据文件
  11. [oracle@localhost ~]$ rman target sys/oracle@oralife nocatalog
  12. RMAN> run {
  13. 2> startup force mount;
  14. 3> sql 'alter database datafile 5 offline';
  15. 4> sql 'alter database open';
  16. 5> set newname for datafile 5 to '$ORACLE_BASE/product/10.2.0/oradata/oralife/example01.dbf';
  17. 6> restore datafile 5;
  18. 7> switch datafile 5;
  19. 8> recover datafile 5;
  20. 9> sql 'alter database datafile 5 online';
  21. 10> }
  22. SQL> select file#,name from v$datafile where file#=5;
  23.  FILE# NAME
  24.  ---------- -------------------------------------------------------
  25. 5 /oracle/10g/oracle/product/10.2.0/oradata/oralife/example01.dbf
  26. SQL> select file#,error from v$recover_file;
  27. no rows selected
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved