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

User Management Complete Recovery in ARCHIVELOG Mode

[日期:2012-02-03] 来源:Linux社区  作者:jlh_huahua [字体:大 中 小]
第四种情况:Recovery File Without a Backup
1. Datafile is lost that was never backed up
2. Cannot be used when it is a file from the SYSTEM tablespace
3. Cannot be used if the control file has been recreated
If a datafile is damaged and no backup of the file is available, then you can still recover the datafile if:
1. All archive log files written after the creation of the original datafile are available
2. The control file contains the name of the damaged file(that is, the control file is current, or is a backup taken after the damaged datafile was added to the database)
Note: You cannot re-created any of the datafile for the SYSTEM tablespace by using the CREATE DATAFILE cluase of the ALTER DATABASE statement because the neccessary redo is not available.


Re-create Lost Datafiles
1. Used when missing datafile cannot be restored because it had never been backed up.
2. Description of missing datafile is still in data dictionary and control file
3. Re-create the datafile : SQL> ALTER DATABASE CREATE DATAFILE 'filename';
4. Re-create the datafile with a different filename;
5. SQL> ALTER DATABASE CREATE DATAFILE 'filename' AS 'new file name';


Step:
1. Take te datafile or tablespace offline
2. Re-create the datafile
3. Apply archived log file and redo log file
4. Bring the datafile or tablespace online

[sql]
  1. 实验环境:  
  2. sys@DENVER> CREATE TABLESPACE app2 DATAFILE '/u01/oradata/md/app02_01.dbf' SIZE 10M;  
  3.   
  4. Tablespace created.  
  5.   
  6. sys@DENVER> conn user1/user1  
  7. Connected.  
  8. user1@DENVER> CREATE TABLE t2(id int, name varchar2(20)) TABLESPACE app2;  
  9.   
  10. Table created.  
  11.   
  12. user1@DENVER> INSERT INTO t2 VALUES(0,'recvery 4');  
  13.   
  14. 1 row created.  
  15.   
  16. sys@DENVER> COMMIT;  
  17.   
  18. Commit complete.  
  19.   
  20. user1@DENVER> SELECT * FROM t2;  
  21.   
  22.         ID NAME  
  23. ---------- --------------------   
  24.          0 recvery 4  
  25.   
  26. user1@DENVER> conn /as sysdba  
  27. Connected.  
  28. sys@DENVER> ALTER SYSTEM CHECKPOINT;  
  29.   
  30. System altered.  
  31.   
  32. sys@DENVER> !ls -l /u01/oradata/md/  
  33. total 2276416  
  34. -rw-r----- 1 Oracle oinstall  10493952 Jan  7 09:35 app02_01.dbf   
  35. -rw-r----- 1 oracle oinstall  10493952 Jan  7 09:35 app1_01.dbf   
  36. -rw-r----- 1 oracle oinstall   9846784 Jan  7 09:35 control01.ctl   
  37. .............................  
  38.   
  39. sys@DENVER> !rm -f /u01/oradata/md/app02_01.dbf  
  40.   
  41. sys@DENVER> !ls -l /u01/oradata/md/  
  42. total 2266148  
  43. -rw-r----- 1 oracle oinstall  10493952 Jan  7 09:35 app1_01.dbf   
  44. -rw-r----- 1 oracle oinstall   9846784 Jan  7 09:36 control01.ctl   
  45. .............................  
  46.   
  47. sys@DENVER> SELECT * FROM v$recover_file;  
  48.   
  49. no rows selected  
  50.   
  51. sys@DENVER> col name format a50  
  52. sys@DENVER> SELECT file#, name FROM v$datafile ORDER BY 1;  
  53.   
  54.      FILE# NAME  
  55. ---------- --------------------------------------------------   
  56.          1 /u01/oradata/md/system01.dbf  
  57.          2 /u01/oradata/md/sysaux01.dbf  
  58.          3 /u01/oradata/md/undotbs01.dbf  
  59.          4 /u01/oradata/md/users01.dbf  
  60.          5 /u01/oradata/md/example01.dbf  
  61.          6 /u01/oradata/md/perfstat_01.dbf  
  62.          7 /u01/oradata/md/user02.dbf  
  63.          8 /u01/oradata/md/tools01.dbf  
  64.          9 /u01/oradata/md/app1_01.dbf  
  65.         10 /u01/oradata/md/app02_01.dbf  
  66.   
  67. 10 rows selected.  
  68.   
  69. sys@DENVER> alter database datafile 10 offline;  
  70.   
  71. Database altered.  
  72.   
  73. sys@DENVER> alter database create datafile '/u01/oradata/md/app02_01.dbf';  
  74.   
  75. Database altered.  
  76.   
  77. sys@DENVER> select * from user1.t2;  
  78. select * from user1.t2  
  79.                     *  
  80. ERROR at line 1:  
  81. ORA-00376: file 10 cannot be read at this time  
  82. ORA-01110: data file 10: '/u01/oradata/md/app02_01.dbf'  
  83.   
  84.   
  85. sys@DENVER> recover datafile 10;  
  86. Media recovery complete.  
  87.   
  88. sys@DENVER> alter database datafile 10 online;  
  89.   
  90. Database altered.  
  91.   
  92. sys@DENVER> select * from user1.t2;  
  93.   
  94.         ID NAME  
  95. ---------- --------------------------------------------------   
  96.          0 recvery 4  
  97.          1 test  
  98.   
  99. sys@DENVER>   
linux
相关资讯       Oracle基础教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

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