rebuild controlfile

1. 以sysdba登陆,导出控制文件

Sql代码
  1. alterdatabasebackupcontrolfiletotrace;

2. 在%oracle_base%/oradata/%oracle_sid%/udump下找到刚刚创建的trc文件,打开它。可以看到里面包含了两段sql脚本。

Sql代码
  1. --BelowaretwosetsofSQLstatements,eachofwhichcreatesanew
  2. --controlfileandusesittoopenthedatabase.Thefirstsetopens
  3. --thedatabasewiththeNORESETLOGSoptionandshouldbeusedonlyif
  4. --thecurrentversionsofallonlinelogsareavailable.Thesecond
  5. --setopensthedatabasewiththeRESETLOGSoptionandshouldbeused
  6. --ifonlinelogsareunavailable.
  7. --Theappropriatesetofstatementscanbecopiedfromthetraceinto
  8. --ascriptfile,editedasnecessary,andexecutedwhenthereisa
  9. --needtore-createthecontrolfile.
  10. --
  11. --Set#1.NORESETLOGScase
  12. --
  13. --Thefollowingcommandswillcreateanewcontrolfileanduseit
  14. --toopenthedatabase.
  15. --DatausedbyRecoveryManagerwillbelost.
  16. --Additionallogsmayberequiredformediarecoveryofoffline
  17. --Usethisonlyifthecurrentversionsofallonlinelogsare
  18. --available.
  19. --Aftermountingthecreatedcontrolfile,thefollowingSQL
  20. --statementwillplacethedatabaseintheappropriate
  21. --protectionmode:
  22. --ALTERDATABASESETSTANDBYDATABASETOMAXIMIZEPERFORMANCE
  23. STARTUPNOMOUNT
  24. CREATECONTROLFILEREUSEDATABASE"EPCIT"NORESETLOGSARCHIVELOG
  25. MAXLOGFILES16
  26. MAXLOGMEMBERS3
  27. MAXDATAFILES100
  28. MAXINSTANCES8
  29. MAXLOGHISTORY454
  30. LOGFILE
  31. GROUP1'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITREDO01.LOG'SIZE10M,
  32. GROUP2'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITREDO02.LOG'SIZE10M,
  33. GROUP3'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITREDO03.LOG'SIZE10M
  34. --STANDBYLOGFILE
  35. DATAFILE
  36. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITSYSTEM01.DBF',
  37. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITUNDOTBS01.DBF',
  38. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITSYSAUX01.DBF',
  39. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITBLOBS01.DBF',
  40. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITINDEX01.DBF',
  41. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITUSERS01.DBF',
  42. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITWCAUDIT01.DBF'
  43. CHARACTERSETUTF8
  44. ;
  45. --ConfigureRMANconfigurationrecord1
  46. VARIABLERECNONUMBER;
  47. EXECUTE:RECNO:=SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CHANNEL','DEVICETYPEDISKMAXPIECESIZE100M');
  48. --ConfigureRMANconfigurationrecord3
  49. VARIABLERECNONUMBER;
  50. EXECUTE:RECNO:=SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILEAUTOBACKUP','ON');
  51. --ConfigureRMANconfigurationrecord4
  52. VARIABLERECNONUMBER;
  53. EXECUTE:RECNO:=SYS.DBMS_BACKUP_RESTORE.SETCONFIG('BACKUPOPTIMIZATION','ON');
  54. --ConfigureRMANconfigurationrecord5
  55. VARIABLERECNONUMBER;
  56. EXECUTE:RECNO:=SYS.DBMS_BACKUP_RESTORE.SETCONFIG('DEVICETYPE','DISKBACKUPTYPETOCOMPRESSEDBACKUPSETPARALLELISM1');
  57. --Commandstore-createincarnationtable
  58. --BelowlognamesMUSTbechangedtoexistingfilenameson
  59. --disk.Anyonelogfilefromeachbranchcanbeusedto
  60. --re-createincarnationrecords.
  61. --ALTERDATABASEREGISTERLOGFILE'D:/ORACLE/FLASH_RECOVERY_AREA/EPCIT/ARCHIVELOG/2009_02_22/O1_MF_1_1_%U_.ARC';
  62. --Recoveryisrequiredifanyofthedatafilesarerestoredbackups,
  63. --orifthelastshutdownwasnotnormalorimmediate.
  64. RECOVERDATABASE
  65. --Alllogsneedarchivingandalogswitchisneeded.
  66. ALTERSYSTEMARCHIVELOGALL;
  67. --Databasecannowbeopenednormally.
  68. ALTERDATABASEOPEN;
  69. --Commandstoaddtempfilestotemporarytablespaces.
  70. --Onlinetempfileshavecompletespaceinformation.
  71. --Othertempfilesmayrequireadjustment.
  72. ALTERTABLESPACETEMPADDTEMPFILE'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITTEMP01.DBF'
  73. SIZE209715200REUSEAUTOEXTENDONNEXT655360MAXSIZE32767M;
  74. --Endoftempfileadditions.
  75. --
  76. --Set#2.RESETLOGScase
  77. --
  78. --Thefollowingcommandswillcreateanewcontrolfileanduseit
  79. --toopenthedatabase.
  80. --DatausedbyRecoveryManagerwillbelost.
  81. --Thecontentsofonlinelogswillbelostandallbackupswill
  82. --beinvalidated.Usethisonlyifonlinelogsaredamaged.
  83. --Aftermountingthecreatedcontrolfile,thefollowingSQL
  84. --statementwillplacethedatabaseintheappropriate
  85. --protectionmode:
  86. --ALTERDATABASESETSTANDBYDATABASETOMAXIMIZEPERFORMANCE
  87. STARTUPNOMOUNT
  88. CREATECONTROLFILEREUSEDATABASE"EPCIT"RESETLOGSARCHIVELOG
  89. MAXLOGFILES16
  90. MAXLOGMEMBERS3
  91. MAXDATAFILES100
  92. MAXINSTANCES8
  93. MAXLOGHISTORY454
  94. LOGFILE
  95. GROUP1'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITREDO01.LOG'SIZE10M,
  96. GROUP2'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITREDO02.LOG'SIZE10M,
  97. GROUP3'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITREDO03.LOG'SIZE10M
  98. --STANDBYLOGFILE
  99. DATAFILE
  100. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITSYSTEM01.DBF',
  101. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITUNDOTBS01.DBF',
  102. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITSYSAUX01.DBF',
  103. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITBLOBS01.DBF',
  104. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITINDEX01.DBF',
  105. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITUSERS01.DBF',
  106. 'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITWCAUDIT01.DBF'
  107. CHARACTERSETUTF8
  108. ;
  109. --ConfigureRMANconfigurationrecord1
  110. VARIABLERECNONUMBER;
  111. EXECUTE:RECNO:=SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CHANNEL','DEVICETYPEDISKMAXPIECESIZE100M');
  112. --ConfigureRMANconfigurationrecord3
  113. VARIABLERECNONUMBER;
  114. EXECUTE:RECNO:=SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILEAUTOBACKUP','ON');
  115. --ConfigureRMANconfigurationrecord4
  116. VARIABLERECNONUMBER;
  117. EXECUTE:RECNO:=SYS.DBMS_BACKUP_RESTORE.SETCONFIG('BACKUPOPTIMIZATION','ON');
  118. --ConfigureRMANconfigurationrecord5
  119. VARIABLERECNONUMBER;
  120. EXECUTE:RECNO:=SYS.DBMS_BACKUP_RESTORE.SETCONFIG('DEVICETYPE','DISKBACKUPTYPETOCOMPRESSEDBACKUPSETPARALLELISM1');
  121. --Commandstore-createincarnationtable
  122. --BelowlognamesMUSTbechangedtoexistingfilenameson
  123. --disk.Anyonelogfilefromeachbranchcanbeusedto
  124. --re-createincarnationrecords.
  125. --ALTERDATABASEREGISTERLOGFILE'D:/ORACLE/FLASH_RECOVERY_AREA/EPCIT/ARCHIVELOG/2009_02_22/O1_MF_1_1_%U_.ARC';
  126. --Recoveryisrequiredifanyofthedatafilesarerestoredbackups,
  127. --orifthelastshutdownwasnotnormalorimmediate.
  128. RECOVERDATABASEUSINGBACKUPCONTROLFILE
  129. --Databasecannowbeopenedzeroingtheonlinelogs.
  130. ALTERDATABASEOPENRESETLOGS;
  131. --Commandstoaddtempfilestotemporarytablespaces.
  132. --Onlinetempfileshavecompletespaceinformation.
  133. --Othertempfilesmayrequireadjustment.
  134. ALTERTABLESPACETEMPADDTEMPFILE'D:/PTC/OCU_8.0/ORADATA/EPCIT/EPCITTEMP01.DBF'
  135. SIZE209715200REUSEAUTOEXTENDONNEXT655360MAXSIZE32767M;
  136. --Endoftempfileadditions.

第一段sql是在所有online redolog没有丢失,以noresetlogs选项打开数据库的情况下使用的。第二段则是在丢失了online redolog需要resetlogs的情况下使用。

3. 把"Set #1. NORESETLOGS case"下的sql拷贝出来,存为reCreateCtl.sql

4. 以sysdba登陆,shutdown immediate。然后删除所有控制文件。再运行reCreateCtl.sql。

Sql代码
  1. SQL>@reCreateCtl
  2. ORACLEinstancestarted.
  3. TotalSystemGlobalArea251658240bytes
  4. FixedSize1248356bytes
  5. VariableSize83887004bytes
  6. DatabaseBuffers159383552bytes
  7. RedoBuffers7139328bytes
  8. Controlfilecreated.
  9. PL/SQLproceduresuccessfullycompleted.
  10. PL/SQLproceduresuccessfullycompleted.
  11. PL/SQLproceduresuccessfullycompleted.
  12. PL/SQLproceduresuccessfullycompleted.
  13. ORA-00283:recoverysessioncanceledduetoerrors
  14. ORA-00264:norecoveryrequired
  15. Systemaltered.
  16. Databasealtered.
  17. Tablespacealtered.

5. 成功创建了控制文件,数据库也正常打开。再没有使用Recovery Catalog的情况下,RMAN的备份资料是存在控制文件中的,重建控制文件会导致丢失备份资料库。

from:http://logicgate.javaeye.com/blog/336705

http://www.itpub.net/thread-188958-1-1.html

http://www.eygle.com/faq/How.To.Backup.and.Recreate.Controlfile.htm

你可能感兴趣的:(Build)