你好,游客 登录 注册 搜索
背景:
阅读新闻

User Management Complete Recovery in ARCHIVELOG Mode

[日期:2012-02-03] 来源:Linux社区  作者:jlh_huahua [字体:大 中 小]
第三种情况: Recovery When the Database is Initially Closed
Use this method when:
1. The database is currently closed
2. The database will be opened during recovery
3. The media failure does not affect the SYSTEM tablespace
Step:
1. Mount the database
2. Take datafile offline
3. Open the database
4. Restore datafile
5. Apply archved redo log and online redo log file
6. Bring the datafile online
实验环境:

备份文件中没有'4 recovery 3'这条记录。

[sql]
  1. sys@DENVER> select * from user1.t;  
  2.   
  3.         ID NAME  
  4. ---------- ----------   
  5.          0 bbk  
  6.          1 bbk  
  7.          2 bbk  
  8.          3 bbk  
  9.   
  10. 4 rows selected.  
  11.   
  12. sys@DENVER> insert into user1.t values(4,'recover 3');  
  13.   
  14. 1 row created.  
  15.   
  16. sys@DENVER> commit;  
  17.   
  18. Commit complete.  
  19.   
  20. sys@DENVER> !ls -l /u01/admin/denver/archdest  
  21. total 15600  
  22. -rw-r----- 1 Oracle oinstall 15949312 Jan  7 09:03 1_1_771929980.arc   
  23.   
  24. sys@DENVER> alter system switch logfile;  
  25.   
  26. System altered.  
  27.   
  28. sys@DENVER> !ls -l /u01/admin/denver/archdest  
  29. total 15876  
  30. -rw-r----- 1 oracle oinstall 15949312 Jan  7 09:03 1_1_771929980.arc   
  31. -rw-r----- 1 oracle oinstall   270848 Jan  7 09:17 1_2_771929980.arc   
  32.   
  33. sys@DENVER> shutdown immediate  
  34. Database closed.  
  35. Database dismounted.  
  36. ORACLE instance shut down.  
  37. sys@DENVER> quit  
  38. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production  
  39. With the Partitioning, OLAP, Data Mining and Real Application Testing options  
  40. [oracle@oracle11gR2 ~]$ rm -f /u01/oradata/md/app1_01.dbf   
  41. [oracle@oracle11gR2 ~]$ ls -l /u01/oradata/md/  
  42. total 2255880  
  43. -rw-r----- 1 oracle oinstall   9846784 Jan  7 09:17 control01.ctl   
  44. -rw-r----- 1 oracle oinstall 104865792 Jan  7 09:17 example01.dbf   
  45. -rw-r----- 1 oracle oinstall 536879104 Jan  7 09:17 perfstat_01.dbf   
  46. ..........................  
  47.   
  48. [oracle@oracle11gR2 ~]$ sqlplus /nolog  
  49.   
  50. SQL*Plus: Release 11.2.0.1.0 Production on Sat Jan 7 09:19:13 2012  
  51.   
  52. Copyright (c) 1982, 2009, Oracle.  All rights reserved.  
  53.   
  54. idle> conn /as sysdba  
  55. Connected to an idle instance.  
  56. idle> startup  
  57. ORACLE instance started.  
  58.   
  59. Total System Global Area  422670336 bytes  
  60. Fixed Size                  1336960 bytes  
  61. Variable Size             314575232 bytes  
  62. Database Buffers          100663296 bytes  
  63. Redo Buffers                6094848 bytes  
  64. Database mounted.  
  65. ORA-01157: cannot identify/lock data file 9 - see DBWR trace file  
  66. ORA-01110: data file 9: '/u01/oradata/md/app1_01.dbf'  
  67.   
  68.   
  69. idle> col error format a20  
  70. idle> select * from v$recover_file;  
  71.   
  72.      FILE# ONLINE  ONLINE_ ERROR                   CHANGE# TIME  
  73. ---------- ------- ------- -------------------- ---------- ---------   
  74.          9 ONLINE  ONLINE  FILE NOT FOUND                0  
  75.   
  76. idle> alter database datafile 9 offline;  
  77.   
  78. Database altered.  
  79.   
  80. idle> alter database open;  
  81.   
  82. Database altered.  
  83.   
  84. idle> select count(*) from hr.employees;  
  85.   
  86.   COUNT(*)  
  87. ----------   
  88.        107  
  89.   
  90. idle> select * from user1.t;  
  91. select * from user1.t  
  92.                     *  
  93. ERROR at line 1:  
  94. ORA-00376: file 9 cannot be read at this time  
  95. ORA-01110: data file 9: '/u01/oradata/md/app1_01.dbf'  
  96.   
  97.   
  98. idle> !cp /tmp/backup/cold/app1_01.dbf /u01/oradata/md/  
  99.   
  100. idle> !ls -l /u01/oradata/md  
  101. total 2266148  
  102. -rw-r----- 1 oracle oinstall  10493952 Jan  7 09:21 app1_01.dbf   
  103. -rw-r----- 1 oracle oinstall   9846784 Jan  7 09:21 control01.ctl   
  104. -rw-r----- 1 oracle oinstall 104865792 Jan  7 09:20 example01.dbf   
  105. -rw-r----- 1 oracle oinstall 536879104 Jan  7 09:20 perfstat_01.dbf   
  106. ..................  
  107.   
  108. idle> recover datafile 9;  
  109. Media recovery complete.  
  110. idle> alter database datafile 9 online;  
  111.   
  112. Database altered.  
  113.   
  114. idle> select * from user1.t;  
  115.   
  116.         ID NAME  
  117. ---------- ----------   
  118.          0 bbk  
  119.          1 bbk  
  120.          2 bbk  
  121.          3 bbk  
  122.          4 recover 3  
linux
相关资讯       Oracle基础教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款