首页 > 数据库技术 > 详细

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

时间:2016-05-12 02:06:20      阅读:236      评论:0      收藏:0      [点我收藏+]
        控制文件(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. -- LOG_ARCHIVE_DEST_1=‘MANDATORY NOREOPEN NODELAY
  36. -- LOG_ARCHIVE_DEST_1=‘ARCH NOAFFIRM EXPEDITE NOVERIFY SYNC
  37. -- LOG_ARCHIVE_DEST_1=‘NOREGISTER NOALTERNATE NODEPENDENCY
  38. -- LOG_ARCHIVE_DEST_1=‘NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME
  39. -- LOG_ARCHIVE_DEST_1=‘VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)
  40. -- LOG_ARCHIVE_DEST_STATE_1=ENABLE
  41. --
  42. -- Below are two sets of SQL statements, each of which creates a new
  43. -- control file and uses it to open the database. The first set opens
  44. -- the database with the NORESETLOGS option and should be used only if
  45. -- the current versions of all online logs are available. The second
  46. -- set opens the database with the RESETLOGS option and should be used
  47. -- if online logs are unavailable.
  48. -- The appropriate set of statements can be copied from the trace into
  49. -- a script file, edited as necessary, and executed when there is a
  50. -- need to re-create the control file.
  51. --
  52. -- Set #1. NORESETLOGS case
  53. --
  54. -- The following commands will create a new control file and use it
  55. -- to open the database.
  56. -- Data used by Recovery Manager will be lost.
  57. -- Additional logs may be required for media recovery of offline
  58. -- Use this only if the current versions of all online logs are
  59. -- available.
  60. -- After mounting the created controlfile, the following SQL
  61. -- statement will place the database in the appropriate
  62. -- protection mode:
  63. -- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
  64. STARTUP NOMOUNT
  65. CREATE CONTROLFILE REUSE DATABASE "HOEGH" NORESETLOGS NOARCHIVELOG
  66.     MAXLOGFILES 16
  67.     MAXLOGMEMBERS 3
  68.     MAXDATAFILES 100
  69.     MAXINSTANCES 8
  70.     MAXLOGHISTORY 292
  71. LOGFILE
  72.   GROUP 1 ‘/u01/app/oracle/oradata/HOEGH/redo01.log‘ SIZE 50M BLOCKSIZE 512,
  73.   GROUP 2 ‘/u01/app/oracle/oradata/HOEGH/redo02.log‘ SIZE 50M BLOCKSIZE 512,
  74.   GROUP 3 ‘/u01/app/oracle/oradata/HOEGH/redo03.log‘ SIZE 50M BLOCKSIZE 512
  75. -- STANDBY LOGFILE
  76. DATAFILE
  77.   ‘/u01/app/oracle/oradata/HOEGH/system01.dbf‘,
  78.   ‘/u01/app/oracle/oradata/HOEGH/sysaux01.dbf‘,
  79.   ‘/u01/app/oracle/oradata/HOEGH/undotbs01.dbf‘,
  80.   ‘/u01/app/oracle/oradata/HOEGH/users01.dbf‘,
  81.   ‘/u01/app/oracle/oradata/HOEGH/example01.dbf‘,
  82.   ‘/u01/app/oracle/oradata/HOEGH/test01.dbf
  83. CHARACTER SET AL32UTF8
  84. ;
  85. -- Commands to re-create incarnation table
  86. -- Below log names MUST be changed to existing filenames on
  87. -- disk. Any one log file from each branch can be used to
  88. -- re-create incarnation records.
  89. -- ALTER DATABASE REGISTER LOGFILE ‘/u01/app/oracle/product/11.2.0/dbhome_1/dbs/
  90. arch1_1_762197622.dbf‘;
  91. -- ALTER DATABASE REGISTER LOGFILE ‘/u01/app/oracle/product/11.2.0/dbhome_1/dbs/
  92. arch1_1_860888149.dbf‘;
  93. -- Recovery is required if any of the datafiles are restored backups,
  94. -- or if the last shutdown was not normal or immediate.
  95. RECOVER DATABASE
  96. -- Database can now be opened normally.
  97. ALTER DATABASE OPEN;
  98. -- Commands to add tempfiles to temporary tablespaces.
  99. -- Online tempfiles have complete space information.
  100. -- Other tempfiles may require adjustment.
  101. ALTER TABLESPACE TEMP ADD TEMPFILE ‘/u01/app/oracle/oradata/HOEGH/temp01.dbf
  102.      SIZE 30408704 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
  103. -- End of tempfile additions.
  104. --
  105. -- Set #2. RESETLOGS case
  106. --
  107. -- The following commands will create a new control file and use it
  108. -- to open the database.
  109. -- Data used by Recovery Manager will be lost.
  110. -- The contents of online logs will be lost and all backups will
  111. -- be invalidated. Use this only if online logs are damaged.
  112. -- After mounting the created controlfile, the following SQL
  113. -- statement will place the database in the appropriate
  114. -- protection mode:
  115. -- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
  116. STARTUP NOMOUNT
  117. CREATE CONTROLFILE REUSE DATABASE "HOEGH" RESETLOGS NOARCHIVELOG
  118.     MAXLOGFILES 16
  119.     MAXLOGMEMBERS 3
  120.     MAXDATAFILES 100
  121.     MAXINSTANCES 8
  122.     MAXLOGHISTORY 292
  123. LOGFILE
  124.   GROUP 1 ‘/u01/app/oracle/oradata/HOEGH/redo01.log‘ SIZE 50M BLOCKSIZE 512,
  125.   GROUP 2 ‘/u01/app/oracle/oradata/HOEGH/redo02.log‘ SIZE 50M BLOCKSIZE 512,
  126.   GROUP 3 ‘/u01/app/oracle/oradata/HOEGH/redo03.log‘ SIZE 50M BLOCKSIZE 512
  127. -- STANDBY LOGFILE
  128. DATAFILE
  129.   ‘/u01/app/oracle/oradata/HOEGH/system01.dbf‘,
  130.   ‘/u01/app/oracle/oradata/HOEGH/sysaux01.dbf‘,
  131.   ‘/u01/app/oracle/oradata/HOEGH/undotbs01.dbf‘,
  132.   ‘/u01/app/oracle/oradata/HOEGH/users01.dbf‘,
  133.   ‘/u01/app/oracle/oradata/HOEGH/example01.dbf‘,
  134.   ‘/u01/app/oracle/oradata/HOEGH/test01.dbf
  135. CHARACTER SET AL32UTF8
  136. ;
  137. -- Commands to re-create incarnation table
  138. -- Below log names MUST be changed to existing filenames on
  139. -- disk. Any one log file from each branch can be used to
  140. -- re-create incarnation records.
  141. -- ALTER DATABASE REGISTER LOGFILE ‘/u01/app/oracle/product/11.2.0/dbhome_1/dbs/
  142. arch1_1_762197622.dbf‘;
  143. -- ALTER DATABASE REGISTER LOGFILE ‘/u01/app/oracle/product/11.2.0/dbhome_1/dbs/
  144. arch1_1_860888149.dbf‘;
  145. -- Recovery is required if any of the datafiles are restored backups,
  146. -- or if the last shutdown was not normal or immediate.
  147. RECOVER DATABASE USING BACKUP CONTROLFILE
  148. -- Database can now be opened zeroing the online logs.
  149. ALTER DATABASE OPEN RESETLOGS;
  150. -- Commands to add tempfiles to temporary tablespaces.
  151. -- Online tempfiles have complete space information.
  152. -- Other tempfiles may require adjustment.
  153. ALTER TABLESPACE TEMP ADD TEMPFILE ‘/u01/app/oracle/oradata/HOEGH/temp01.dbf
我们可以看到转储文件里包含了数据库的名字、数据文件的位置等信息,并且按照是否需要resetlogs分别给出了创建控制文件的sql语句。控制文件非常重要,我们可以把它备份下来以防万一。

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

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

原文:http://blog.itpub.net/30162081/viewspace-2096756/

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!