您的位置:首页 > 数据库 > Oracle

如何查看Oracle11g控制文件里面的内容

2016-05-09 22:46 477 查看
        控制文件(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/30162081/viewspace-2096756/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30162081/viewspace-2096756/

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐