如何檢視Oracle11g控制檔案裡面的內容

dbasdk發表於2016-05-21
        控制檔案(Control File)是Oracle的物理檔案之一,它記錄了資料庫的名字、資料檔案的位置等資訊。控制檔案的重要性在於,一旦控制檔案損壞,資料庫將會當機。控制檔案是一個很小的二進位制檔案,使用者不能編輯控制檔案,控制檔案的修改由Oracle自動完成。那麼,我們能夠檢視控制檔案裡面的具體資訊嗎?答案是可以的,我們可以透過轉儲檔案來獲得控制檔案的詳細資訊。
1.生成控制檔案的轉儲檔案

點選(此處)摺疊或開啟

  1. SQL> select * from v$version;

  2. BANNER
  3. --------------------------------------------------------------------------------
  4. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
  5. PL/SQL Release 11.2.0.3.0 - Production
  6. CORE 11.2.0.3.0 Production
  7. TNS for Linux: Version 11.2.0.3.0 - Production
  8. NLSRTL Version 11.2.0.3.0 - Production

  9. SQL> alter database backup controlfile to trace ;

  10. Database altered.

  11. SQL>
2.查詢生成的轉儲檔案
我們知道,使用者生成的TRACE檔案儲存在udump目錄下。在Oracle10g中,udump路徑是$ORACLE_HOME/admin/SID/udump,而Oracle11g則大不一樣。我們可以透過檢視user_dump_dest引數來定位udump目錄的具體位置。

點選(此處)摺疊或開啟

  1. SQL> show parameter user_dump_dest

  2. NAME TYPE VALUE
  3. ------------------------------------ ----------- ------------------------------
  4. user_dump_dest string /u01/app/oracle/diag/rdbms/hoegh/HOEGH/trace
  5. SQL>
然後,我們使用ls命令找到最近生成的TRACE檔案,就是圖示的HOEGH_ora_304.trc檔案。

點選(此處)摺疊或開啟

  1. [oracle@hoegh trace]$ ls -ltr
  2. total 1332
  3. 此處省略三百字
  4. -rw-r----- 1 oracle oinstall 932 May 9 21:26 HOEGH_mmon_4805.trm
  5. -rw-r----- 1 oracle oinstall 9750 May 9 21:26 HOEGH_mmon_4805.trc
  6. -rw-r----- 1 oracle oinstall 4562 May 9 21:28 HOEGH_dbrm_4789.trm
  7. -rw-r----- 1 oracle oinstall 80534 May 9 21:28 HOEGH_dbrm_4789.trc
  8. -rw-r----- 1 oracle oinstall 97 May 9 21:29 HOEGH_ora_304.trm
  9. -rw-r----- 1 oracle oinstall 12786 May 9 21:29 HOEGH_ora_304.trc
3.檢視控制檔案具體資訊
現在,我們就可以透過more命令來檢視控制檔案的具體資訊了。

點選(此處)摺疊或開啟

  1. [oracle@hoegh trace]$ more HOEGH_ora_304.trc
  2. Trace file /u01/app/oracle/diag/rdbms/hoegh/HOEGH/trace/HOEGH_ora_304.trc
  3. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
  4. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  5. ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1
  6. System name: Linux
  7. Node name: hoegh.example.com
  8. Release: 2.6.18-164.el5PAE
  9. Version: #1 SMP Thu Sep 3 02:28:20 EDT 2009
  10. Machine: i686
  11. VM name: VMWare Version: 6
  12. Instance name: HOEGH
  13. Redo thread mounted by this instance: 1
  14. Oracle process number: 26
  15. Unix process pid: 304, image: oracle@hoegh.example.com (TNS V1-V3)

  16. *** 2016-05-09 21:29:07.246
  17. -- The following are current System-scope REDO Log Archival related
  18. -- parameters and can be included in the database initialization file.
  19. --
  20. -- LOG_ARCHIVE_DEST=''
  21. -- LOG_ARCHIVE_DUPLEX_DEST=''
  22. --
  23. -- LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf
  24. --
  25. -- DB_UNIQUE_NAME="HOEGH"
  26. --
  27. -- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'
  28. -- LOG_ARCHIVE_MAX_PROCESSES=4
  29. -- STANDBY_FILE_MANAGEMENT=MANUAL
  30. -- STANDBY_ARCHIVE_DEST=?/dbs/arch
  31. -- FAL_CLIENT=''
  32. -- FAL_SERVER=''
  33. --
  34. -- LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
  35. '
  36. -- LOG_ARCHIVE_DEST_1='MANDATORY NOREOPEN NODELAY'
  37. -- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM EXPEDITE NOVERIFY SYNC'
  38. -- LOG_ARCHIVE_DEST_1='NOREGISTER NOALTERNATE NODEPENDENCY'
  39. -- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME'
  40. -- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)'
  41. -- LOG_ARCHIVE_DEST_STATE_1=ENABLE
  42. --
  43. -- Below are two sets of SQL statements, each of which creates a new
  44. -- control file and uses it to open the database. The first set opens
  45. -- the database with the NORESETLOGS option and should be used only if
  46. -- the current versions of all online logs are available. The second
  47. -- set opens the database with the RESETLOGS option and should be used
  48. -- if online logs are unavailable.
  49. -- The appropriate set of statements can be copied from the trace into
  50. -- a script file, edited as necessary, and executed when there is a
  51. -- need to re-create the control file.
  52. --
  53. -- Set #1. NORESETLOGS case
  54. --
  55. -- The following commands will create a new control file and use it
  56. -- to open the database.
  57. -- Data used by Recovery Manager will be lost.
  58. -- Additional logs may be required for media recovery of offline
  59. -- Use this only if the current versions of all online logs are
  60. -- available.
  61. -- After mounting the created controlfile, the following SQL
  62. -- statement will place the database in the appropriate
  63. -- protection mode:
  64. -- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
  65. STARTUP NOMOUNT
  66. CREATE CONTROLFILE REUSE DATABASE "HOEGH" NORESETLOGS NOARCHIVELOG
  67.     MAXLOGFILES 16
  68.     MAXLOGMEMBERS 3
  69.     MAXDATAFILES 100
  70.     MAXINSTANCES 8
  71.     MAXLOGHISTORY 292
  72. LOGFILE
  73.   GROUP 1 '/u01/app/oracle/oradata/HOEGH/redo01.log' SIZE 50M BLOCKSIZE 512,
  74.   GROUP 2 '/u01/app/oracle/oradata/HOEGH/redo02.log' SIZE 50M BLOCKSIZE 512,
  75.   GROUP 3 '/u01/app/oracle/oradata/HOEGH/redo03.log' SIZE 50M BLOCKSIZE 512
  76. -- STANDBY LOGFILE
  77. DATAFILE
  78.   '/u01/app/oracle/oradata/HOEGH/system01.dbf',
  79.   '/u01/app/oracle/oradata/HOEGH/sysaux01.dbf',
  80.   '/u01/app/oracle/oradata/HOEGH/undotbs01.dbf',
  81.   '/u01/app/oracle/oradata/HOEGH/users01.dbf',
  82.   '/u01/app/oracle/oradata/HOEGH/example01.dbf',
  83.   '/u01/app/oracle/oradata/HOEGH/test01.dbf'
  84. CHARACTER SET AL32UTF8
  85. ;
  86. -- Commands to re-create incarnation table
  87. -- Below log names MUST be changed to existing filenames on
  88. -- disk. Any one log file from each branch can be used to
  89. -- re-create incarnation records.
  90. -- ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/
  91. arch1_1_762197622.dbf';
  92. -- ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/
  93. arch1_1_860888149.dbf';
  94. -- Recovery is required if any of the datafiles are restored backups,
  95. -- or if the last shutdown was not normal or immediate.
  96. RECOVER DATABASE
  97. -- Database can now be opened normally.
  98. ALTER DATABASE OPEN;
  99. -- Commands to add tempfiles to temporary tablespaces.
  100. -- Online tempfiles have complete space information.
  101. -- Other tempfiles may require adjustment.
  102. ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/HOEGH/temp01.dbf'
  103.      SIZE 30408704 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
  104. -- End of tempfile additions.
  105. --
  106. -- Set #2. RESETLOGS case
  107. --
  108. -- The following commands will create a new control file and use it
  109. -- to open the database.
  110. -- Data used by Recovery Manager will be lost.
  111. -- The contents of online logs will be lost and all backups will
  112. -- be invalidated. Use this only if online logs are damaged.
  113. -- After mounting the created controlfile, the following SQL
  114. -- statement will place the database in the appropriate
  115. -- protection mode:
  116. -- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
  117. STARTUP NOMOUNT
  118. CREATE CONTROLFILE REUSE DATABASE "HOEGH" RESETLOGS NOARCHIVELOG
  119.     MAXLOGFILES 16
  120.     MAXLOGMEMBERS 3
  121.     MAXDATAFILES 100
  122.     MAXINSTANCES 8
  123.     MAXLOGHISTORY 292
  124. LOGFILE
  125.   GROUP 1 '/u01/app/oracle/oradata/HOEGH/redo01.log' SIZE 50M BLOCKSIZE 512,
  126.   GROUP 2 '/u01/app/oracle/oradata/HOEGH/redo02.log' SIZE 50M BLOCKSIZE 512,
  127.   GROUP 3 '/u01/app/oracle/oradata/HOEGH/redo03.log' SIZE 50M BLOCKSIZE 512
  128. -- STANDBY LOGFILE
  129. DATAFILE
  130.   '/u01/app/oracle/oradata/HOEGH/system01.dbf',
  131.   '/u01/app/oracle/oradata/HOEGH/sysaux01.dbf',
  132.   '/u01/app/oracle/oradata/HOEGH/undotbs01.dbf',
  133.   '/u01/app/oracle/oradata/HOEGH/users01.dbf',
  134.   '/u01/app/oracle/oradata/HOEGH/example01.dbf',
  135.   '/u01/app/oracle/oradata/HOEGH/test01.dbf'
  136. CHARACTER SET AL32UTF8
  137. ;
  138. -- Commands to re-create incarnation table
  139. -- Below log names MUST be changed to existing filenames on
  140. -- disk. Any one log file from each branch can be used to
  141. -- re-create incarnation records.
  142. -- ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/
  143. arch1_1_762197622.dbf';
  144. -- ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/
  145. arch1_1_860888149.dbf';
  146. -- Recovery is required if any of the datafiles are restored backups,
  147. -- or if the last shutdown was not normal or immediate.
  148. RECOVER DATABASE USING BACKUP CONTROLFILE
  149. -- Database can now be opened zeroing the online logs.
  150. ALTER DATABASE OPEN RESETLOGS;
  151. -- Commands to add tempfiles to temporary tablespaces.
  152. -- Online tempfiles have complete space information.
  153. -- Other tempfiles may require adjustment.
  154. ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/HOEGH/temp01.dbf
我們可以看到轉儲檔案裡包含了資料庫的名字、資料檔案的位置等資訊,並且按照是否需要resetlogs分別給出了建立控制檔案的sql語句。控制檔案非常重要,我們可以把它備份下來以防萬一。

~~~~~~~ the end~~~~~~~~~
hoegh
2016.05.09

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29734436/viewspace-2104257/,如需轉載,請註明出處,否則將追究法律責任。

相關文章