ITPub博客

首页 > 数据库 > Oracle > 【RMAN】Data Recovery Advisor 小测试

【RMAN】Data Recovery Advisor 小测试

原创 Oracle 作者:xysoul_云龙 时间:2017-07-25 14:40:02 0 删除 编辑

执行以下语句报错:

点击(此处)折叠或打开

  1. SQL> create table t_a as select * from all_objects;
  2. create table t_a as select * from all_objects
  3.                                   *
  4. ERROR at line 1:
  5. ORA-01116: error in opening database file 4
  6. ORA-01110: data file 4: '/oracle/app/oracle/oradata/mydb/users01.dbf'
  7. ORA-27041: unable to open file
  8. Linux-x86_64 Error: 2: No such file or directory
  9. Additional information: 3

提示找不到该数据文件,那么我们怎么恢复呢,大多是通过rman查看备份,执行restore,recover等相关命令,那么有没有更简单的方式呢?

下面我们来看下:

在 Oracle Database 11g 中,新增的 Data Recovery Advisor 极大地简化了该操作。

执行下面命令

点击(此处)折叠或打开

  1. [oracle@mytest ~]$ rman target /

  2. Recovery Manager: Release 11.2.0.4.0 - Production on Tue Jul 25 13:54:35 2017

  3. Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

  4. connected to target database: MYDB (DBID=2861835083)

  5. RMAN> list failure;   --列出失败的信息

  6. using target database control file instead of recovery catalog
  7. List of Database Failures
  8. =========================

  9. Failure ID Priority Status Time Detected Summary
  10. ---------- -------- --------- ------------- -------
  11. 502 HIGH OPEN 25-JUL-17 One or more non-system datafiles are missing   --数据文件丢失

  12. RMAN> list failure 502 detail;   --关于某项失败的详细信息

  13. List of Database Failures
  14. =========================

  15. Failure ID Priority Status Time Detected Summary
  16. ---------- -------- --------- ------------- -------
  17. 502 HIGH OPEN 25-JUL-17 One or more non-system datafiles are missing
  18.   Impact: See impact for individual child failures
  19.   List of child failures for parent failure ID 502
  20.   Failure ID Priority Status Time Detected Summary
  21.   ---------- -------- --------- ------------- -------
  22.   505 HIGH OPEN 25-JUL-17 Datafile 4: '/oracle/app/oracle/oradata/mydb/users01.dbf' is missing   --具体哪个文件丢失
  23.     Impact: Some objects in tablespace USERS might be unavailable

怎么修复呢?


点击(此处)折叠或打开

  1. RMAN> advise failure;  --执行该命令,查看推荐恢复方式

  2. List of Database Failures
  3. =========================

  4. Failure ID Priority Status Time Detected Summary
  5. ---------- -------- --------- ------------- -------
  6. 502 HIGH OPEN 25-JUL-17 One or more non-system datafiles are missing
  7.   Impact: See impact for individual child failures
  8.   List of child failures for parent failure ID 502
  9.   Failure ID Priority Status Time Detected Summary
  10.   ---------- -------- --------- ------------- -------
  11.   505 HIGH OPEN 25-JUL-17 Datafile 4: '/oracle/app/oracle/oradata/mydb/users01.dbf' is missing
  12.     Impact: Some objects in tablespace USERS might be unavailable

  13. analyzing automatic repair options; this may take some time
  14. allocated channel: ORA_DISK_1
  15. channel ORA_DISK_1: SID=125 device type=DISK
  16. analyzing automatic repair options complete

  17. Mandatory Manual Actions
  18. ========================
  19. no manual actions available

  20. Optional Manual Actions
  21. =======================
  22. 1. If file /oracle/app/oracle/oradata/mydb/users01.dbf was unintentionally renamed or moved, restore it

  23. Automated Repair Options
  24. ========================
  25. Option Repair Description
  26. ------ ------------------
  27. 1 Restore and recover datafile 4
  28.   Strategy: The repair includes complete media recovery with no data loss
  29.   Repair script: /oracle/app/oracle/diag/rdbms/mydb/mydb/hm/reco_2119774466.hm

也可参考文件:动态性能视图 V$IR_MANUAL_CHECKLIST 

开始恢复:

点击(此处)折叠或打开

  1. RMAN> repair failure preview;   --修复预演

  2. Strategy: The repair includes complete media recovery with no data loss
  3. Repair script: /oracle/app/oracle/diag/rdbms/mydb/mydb/hm/reco_2119774466.hm

  4. contents of repair script:   --具体相关命令
  5.    # restore and recover datafile
  6.    sql 'alter database datafile 4 offline';
  7.    restore datafile 4;
  8.    recover datafile 4;
  9.    sql 'alter database datafile 4 online';

  10. RMAN> repair failure;   --开始修复

  11. Strategy: The repair includes complete media recovery with no data loss
  12. Repair script: /oracle/app/oracle/diag/rdbms/mydb/mydb/hm/reco_2119774466.hm

  13. contents of repair script:
  14.    # restore and recover datafile
  15.    sql 'alter database datafile 4 offline';
  16.    restore datafile 4;
  17.    recover datafile 4;
  18.    sql 'alter database datafile 4 online';

  19. Do you really want to execute the above repair (enter YES or NO)? yes    -- 确认输入yes,如果不想输入,可执行repair failure noprompt 
  20. executing repair script

  21. sql statement: alter database datafile 4 offline

  22. Starting restore at 25-JUL-17
  23. using channel ORA_DISK_1

  24. channel ORA_DISK_1: starting datafile backup set restore
  25. channel ORA_DISK_1: specifying datafile(s) to restore from backup set
  26. channel ORA_DISK_1: restoring datafile 00004 to /oracle/app/oracle/oradata/mydb/users01.dbf
  27. channel ORA_DISK_1: reading from backup piece /home/oracle/full_03sa84pg_1_1_3.dat
  28. channel ORA_DISK_1: piece handle=/home/oracle/full_03sa84pg_1_1_3.dat tag=TAG20170725T134816
  29. channel ORA_DISK_1: restored backup piece 1
  30. channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
  31. Finished restore at 25-JUL-17

  32. Starting recover at 25-JUL-17
  33. using channel ORA_DISK_1

  34. starting media recovery
  35. media recovery complete, elapsed time: 00:00:00

  36. Finished recover at 25-JUL-17

  37. sql statement: alter database datafile 4 online
  38. repair failure complete

至此修复完成

运行状况检查:
在 Oracle Database 11g 中,RMAN 中有个新命令 VALIDATE DATABASE 通过检查数据库块中的物理损坏极大地简化了该操作。如果检测到损坏,将记录到自动诊断信息库中。然后,RMAN 将生成输出,下面显示了部分输出:


点击(此处)折叠或打开

  1. RMAN> validate database;

  2. Starting validate at 25-JUL-17
  3. using channel ORA_DISK_1
  4. channel ORA_DISK_1: starting validation of datafile
  5. channel ORA_DISK_1: specifying datafile(s) for validation
  6. input datafile file number=00006 name=/oracle/app/oracle/oradata/mydb/test01.dbf
  7. input datafile file number=00007 name=/backup/test02.dbf
  8. input datafile file number=00008 name=/backup/mydb/undo01.dbf
  9. input datafile file number=00001 name=/oracle/app/oracle/oradata/mydb/system01.dbf
  10. channel ORA_DISK_1: validation complete, elapsed time: 00:00:25
  11. List of Datafiles
  12. =================
  13. File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
  14. ---- ------ -------------- ------------ --------------- ----------
  15. 1 OK 0 15597 97351 2880261
  16.   File Name: /oracle/app/oracle/oradata/mydb/system01.dbf
  17.   Block Type Blocks Failing Blocks Processed
  18.   ---------- -------------- ----------------
  19.   Data 0 64154
  20.   Index 0 13405
  21.   Other 0 4124

  22. File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
  23. ---- ------ -------------- ------------ --------------- ----------
  24. 6 OK 0 13874 262144 2737477
  25.   File Name: /oracle/app/oracle/oradata/mydb/test01.dbf
  26.   Block Type Blocks Failing Blocks Processed
  27.   ---------- -------------- ----------------
  28.   Data 0 150350
  29.   Index 0 95666
  30.   Other 0 2254

  31. File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
  32. ---- ------ -------------- ------------ --------------- ----------
  33. 7 OK 0 17575 131072 2790581
  34.   File Name: /backup/test02.dbf
  35.   Block Type Blocks Failing Blocks Processed
  36.   ---------- -------------- ----------------
  37.   Data 0 17101
  38.   Index 0 95654
  39.   Other 0 742

  40. File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
  41. ---- ------ -------------- ------------ --------------- ----------
  42. 8 OK 0 34161 38400 2880261
  43.   File Name: /backup/mydb/undo01.dbf
  44.   Block Type Blocks Failing Blocks Processed
  45.   ---------- -------------- ----------------
  46.   Data 0 0
  47.   Index 0 0
  48.   Other 0 4239

  49. channel ORA_DISK_1: starting validation of datafile
  50. channel ORA_DISK_1: specifying datafile(s) for validation
  51. input datafile file number=00002 name=/oracle/app/oracle/oradata/mydb/sysaux01.dbf
  52. input datafile file number=00004 name=/oracle/app/oracle/oradata/mydb/users01.dbf
  53. channel ORA_DISK_1: validation complete, elapsed time: 00:00:07
  54. List of Datafiles
  55. =================
  56. File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
  57. ---- ------ -------------- ------------ --------------- ----------
  58. 2 OK 0 21651 78129 2880049
  59.   File Name: /oracle/app/oracle/oradata/mydb/sysaux01.dbf
  60.   Block Type Blocks Failing Blocks Processed
  61.   ---------- -------------- ----------------
  62.   Data 0 15713
  63.   Index 0 11381
  64.   Other 0 29335

  65. File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
  66. ---- ------ -------------- ------------ --------------- ----------
  67. 4 OK 0 154 9948 2734400
  68.   File Name: /oracle/app/oracle/oradata/mydb/users01.dbf
  69.   Block Type Blocks Failing Blocks Processed
  70.   ---------- -------------- ----------------
  71.   Data 0 3930
  72.   Index 0 635
  73.   Other 0 5201

  74. channel ORA_DISK_1: starting validation of datafile
  75. channel ORA_DISK_1: specifying datafile(s) for validation
  76. input datafile file number=00005 name=/oracle/app/oracle/oradata/mydb/example01.dbf
  77. channel ORA_DISK_1: validation complete, elapsed time: 00:00:03
  78. List of Datafiles
  79. =================
  80. File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
  81. ---- ------ -------------- ------------ --------------- ----------
  82. 5 OK 0 32632 47040 2744132
  83.   File Name: /oracle/app/oracle/oradata/mydb/example01.dbf
  84.   Block Type Blocks Failing Blocks Processed
  85.   ---------- -------------- ----------------
  86.   Data 0 9606
  87.   Index 0 1733
  88.   Other 0 3069

  89. channel ORA_DISK_1: starting validation of datafile
  90. channel ORA_DISK_1: specifying datafile(s) for validation
  91. including current control file for validation
  92. including current SPFILE in backup set
  93. channel ORA_DISK_1: validation complete, elapsed time: 00:00:00
  94. List of Control File and SPFILE
  95. ===============================
  96. File Type Status Blocks Failing Blocks Examined
  97. ------------ ------ -------------- ---------------
  98. SPFILE OK 0 2
  99. Control File OK 0 636
  100. Finished validate at 25-JUL-17

当然也可以执行相关其他命令:

validate tablespace users;
validate datafile 1;
 validate datafile 4 block 56;
当然,还可以验证 spfile、controlfilecopy、恢复文件、快速恢复区,等等。


关于Oracle11.2 Data Recovery Advisor 小测试 先到这里。

参考文档:

Oracle Database 11g:
面向 DBA 和开发人员的重要特性

作者:Arup Nanda Oracle ACE 总监







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

请登录后发表评论 登录
全部评论
主要从事Oracle数据库 DBA相关工作,其他操作系统、中间件等也有涉及,热衷分享。岁月老将至,如有幸在江湖中留点踪迹,也是欣慰。 【文盲筱烨】好读书爱运动的IT技术爱好者 微博:文盲筱烨 微信公众号:筱烨视点

注册时间:2014-02-15

  • 博文量
    412
  • 访问量
    1104608