程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle數據庫基礎 >> Oracle數據庫RMAN不完全恢復之基於日志序列號恢復

Oracle數據庫RMAN不完全恢復之基於日志序列號恢復

編輯:Oracle數據庫基礎

基於日志序列號恢復是指恢復數據庫到指定日志序列號的狀態。

  1. --查看歸檔日志信息     
  2. SQL> select * from t_user;    
  3. TEXT    
  4. --------------------     
  5. Java_    
  6. spring_    
  7. spring mvc_    
  8. SQL> insert into t_user select 'Oracle_' from dual;    
  9. 1 row created.    
  10. SQL> commit;    
  11. Commit complete.    
  12. SQL> alter system switch logfile;    
  13. System altered.    
  14. SQL> alter system checkpoint;    
  15. System altered.    
  16. SQL> select sequence#,name,first_change# from v$archived_log where status='A' order by sequence#;    
  17. SEQUENCE# NAME                                                   FIRST_CHANGE#    
  18. ---------- ---------------------------------------------------------------------------------------------------- -------------     
  19. 1 /oracle/10g/Oracle/log/archive_log/archive_1_1_760487088.arclog                                            1214497    
  20. 1 /oracle/10g/Oracle/log/archive_log2/archive_1_1_760487088.arclog                                           1214497    
  21. 1 /oracle/10g/Oracle/product/10.2.0/db_1/Flash_recovery_area/ORALIFE/archivelog/2011_08_29/o1_mf_1_1_7       1214498    
  22. 5q9bh9d_.arc    
  23. 1 /oracle/10g/Oracle/log/archive_log/archive_1_1_760487985.arclog                                            1214498    
  24. 1 /oracle/10g/Oracle/log/archive_log2/archive_1_1_760487985.arclog                                           1214498    
  25. 1 /oracle/10g/Oracle/product/10.2.0/db_1/Flash_recovery_area/ORALIFE/archivelog/2011_08_29/o1_mf_1_1_7       1214497    
  26. 5q95ksf_.arc    
  27. 6 rows selected.    
  28. SQL> insert into t_user select 'Oracle_seq3' from dual;    
  29. 1 row created.    
  30. SQL> commit;    
  31. Commit complete.    
  32. SQL> alter system switch logfile; --生成日志序列號為2的歸檔日志     
  33. System altered.    
  34. SQL> alter system checkpoint;    
  35. System altered.    
  36. SQL> select sequence#,name,first_change# from v$archived_log where status='A' order by sequence#;    
  37. SEQUENCE# NAME                                                     FIRST_CHANGE#    
  38. ---------- ---------------------------------------------------------------------------------------------------- -------------     
  39. 1 /oracle/10g/Oracle/log/archive_log/archive_1_1_760487088.arclog                                            1214497    
  40. 1 /oracle/10g/Oracle/log/archive_log2/archive_1_1_760487088.arclog                                           1214497    
  41. 1 /oracle/10g/Oracle/product/10.2.0/db_1/Flash_recovery_area/ORALIFE/archivelog/2011_08_29/o1_mf_1_1_7       1214497    
  42. 5q95ksf_.arc    
  43. 1 /oracle/10g/Oracle/log/archive_log/archive_1_1_760487985.arclog                                            1214498    
  44. 1 /oracle/10g/Oracle/log/archive_log2/archive_1_1_760487985.arclog                                           1214498    
  45. 1 /oracle/10g/Oracle/product/10.2.0/db_1/Flash_recovery_area/ORALIFE/archivelog/2011_08_29/o1_mf_1_1_7       1214498    
  46. 5q9bh9d_.arc    
  47. 2 /oracle/10g/Oracle/log/archive_log/archive_1_2_760487985.arclog                                            1216167    
  48. SEQUENCE# NAME                                                     FIRST_CHANGE#    
  49. ---------- ---------------------------------------------------------------------------------------------------- -------------     
  50. 2 /oracle/10g/Oracle/log/archive_log2/archive_1_2_760487985.arclog                                           1216167    
  51. 2 /oracle/10g/Oracle/product/10.2.0/db_1/Flash_recovery_area/ORALIFE/archivelog/2011_08_29/o1_mf_1_2_7       1216167    
  52. 5q9cvt1_.arc    
  53. 9 rows selected.    
  54. SQL> insert into t_user select 'Oracle_seq3_act' from dual;    
  55. 1 row created.    
  56. SQL> commit;    
  57. Commit complete.    
  58. SQL> alter system switch logfile; --生成日志序列號為3的歸檔日志     
  59. System altered.    
  60. SQL> alter system checkpoint;    
  61. System altered.    
  62. SQL> select sequence#,name,first_change# from v$archived_log where status='A' order by sequence#;    
  63. SEQUENCE# NAME                                                     FIRST_CHANGE#    
  64. ---------- ---------------------------------------------------------------------------------------------------- -------------     
  65. 1 /oracle/10g/Oracle/log/archive_log/archive_1_1_760487088.arclog                                            1214497    
  66. 1 /oracle/10g/Oracle/log/archive_log2/archive_1_1_760487088.arclog                                           1214497    
  67. 1 /oracle/10g/Oracle/product/10.2.0/db_1/Flash_recovery_area/ORALIFE/archivelog/2011_08_29/o1_mf_1_1_7       1214497    
  68. 5q95ksf_.arc    
  69. 1 /oracle/10g/Oracle/log/archive_log/archive_1_1_760487985.arclog                                            1214498    
  70. 1 /oracle/10g/Oracle/log/archive_log2/archive_1_1_760487985.arclog                                           1214498    
  71. 1 /oracle/10g/Oracle/product/10.2.0/db_1/Flash_recovery_area/ORALIFE/archivelog/2011_08_29/o1_mf_1_1_7       1214498    
  72. 5q9bh9d_.arc    
  73. 2 /oracle/10g/Oracle/log/archive_log/archive_1_2_760487985.arclog                                            1216167    
  74. SEQUENCE# NAME                                                     FIRST_CHANGE#    
  75. ---------- ---------------------------------------------------------------------------------------------------- -------------     
  76. 2 /oracle/10g/Oracle/log/archive_log2/archive_1_2_760487985.arclog                                           1216167    
  77. 2 /oracle/10g/Oracle/product/10.2.0/db_1/Flash_recovery_area/ORALIFE/archivelog/2011_08_29/o1_mf_1_2_7       1216167    
  78. 5q9cvt1_.arc    
  79. 3 /oracle/10g/Oracle/log/archive_log/archive_1_3_760487985.arclog                                            1216186    
  80. 3 /oracle/10g/Oracle/log/archive_log2/archive_1_3_760487985.arclog                                           1216186    
  81. 3 /oracle/10g/Oracle/product/10.2.0/db_1/Flash_recovery_area/ORALIFE/archivelog/2011_08_29/o1_mf_1_3_7       1216186    
  82. 5q9f4d6_.arc    
  83. 12 rows selected.    
  84. --恢復到日志序列號為3時的狀態     
  85. [oracle@localhost ~]$ rman target sys/Oracle@oralife nocatalog    
  86. RMAN> run {    
  87. startup force mount;    
  88. set until sequence=3;    
  89. restore database;    
  90. recover database;    
  91. sql 'alter database open resetlogs';    
  92. }    
  93. --查看,可見不包括日志序列號為3的歸檔日志信息(Oracle_seq3_act),即恢復到日志序列號為2的歸檔日志     
  94. SQL> conn sys/Oracle@oralife as sysdba    
  95. Connected.    
  96. SQL> select * from t_user;    
  97. TEXT    
  98. --------------------     
  99. Java_    
  100. spring_    
  101. Oracle_    
  102. Oracle_seq3    
  103. spring mvc_   

可見不包括日志序列號為3的歸檔日志信息(Oracle_seq3_act),即恢復到日志序列號為2的歸檔日志。

在執行了不完全恢復之後,推薦刪除早期所有備份,重新備份數據庫。

關於Oracle數據庫RMAN不完全恢復之基於日志序列號恢復的相關知識就介紹到這裡了,希望本次的介紹能夠對您有所收獲!

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved