Chinaunix首页 | 论坛 | 博客
  • 博客访问: 56663
  • 博文数量: 12
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 100
  • 用 户 组: 普通用户
  • 注册时间: 2014-02-18 11:07
文章分类
文章存档

2014年(12)

我的朋友

分类: 服务器与存储

2014-02-19 17:04:56

 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

阅读(1259) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~