【ORACLE CONCEPT】控制檔案

renjixinchina發表於2013-03-19

控制檔案(control file)中包含了其所屬資料庫的資訊,例項(instance)在啟動,及正常工作期間都需要存取這些資訊。控制檔案的內容只能由Oracle修改,資料庫管理員或使用者都不應編輯控制檔案。

控制檔案(control file)中主要包含以下內容:
  • 資料庫名(database name)
  • 資料庫建立時的時間戳(timestamp)
  • 屬於此資料庫的資料檔案(datafile)及重做日誌檔案(redo log file)的名稱與儲存位置
  • 表空間(tablespace)資訊
  • 離線(offline)的資料檔案
  • 日誌歷史資訊
  • 歸檔日誌(archived log)資訊
  • 備份集(backup set)與備份塊(backup piece)資訊
  • 資料檔案與重做日誌的備份資訊
  • 資料檔案複製資訊
  • 當前的日誌序列號(log sequence number)
  • 檢查點(checkpoint)資訊

資料庫名(database name)和資料庫建立時間戳(timestamp)都來源於資料庫建立過程。資料庫名既可以來自 DB_NAME 初始化引數中的設定值,也可以來自 CREATE DATABASE 語句中的指定值。

每當新增,重新命名,或移除資料庫中的資料檔案(datafile)及重做日誌檔案(redo log file)時,控制檔案(control file)就會被更新以反映這些資料庫物理結構變化。進行這些記錄的目的是:
  • Oracle可以籍此在資料庫啟動(startup)時識別開啟的資料檔案和重做日誌檔案
  • Oracle可以籍此在恢復資料庫時識別當前可用及需要恢復的檔案

因此,使用者每次更改資料庫的物理結構後(使用 ALTER DATABASE 語句),一定要及時備份控制檔案(control file)。

控制檔案(control file)還被用於儲存檢查點(checkpoint)資訊。每隔三秒鐘,檢查點程式(checkpoint process,CKPT)將會在控制檔案中記錄重做日誌(redo log)檢查點位置(checkpoint position)資訊。當資料庫恢復時,重做日誌中此點之前的重做條目(redo entry)都無需恢復,因為這些資料已經被寫入資料檔案(datafile)中了。


Overview of Control Files

The database control file is a small binary file necessary for the database to start and operate successfully. A control file is updated continuously by Oracle during database use, so it must be available for writing whenever the database is open. If for some reason the control file is not accessible, then the database cannot function properly.

Each control file is associated with only one Oracle database.

Control File Contents

A control file contains information about the associated database that is required for access by an instance, both at startup and during normal operation. Control file information can be modified only by Oracle; no database administrator or user can edit a control file.

Among other things, a control file contains information such as:

  • The database name

  • The timestamp of database creation

  • The names and locations of associated datafiles and redo log files

  • Tablespace information

  • Datafile offline ranges

  • The log history

  • Archived log information

  • Backup set and backup piece information

  • Backup datafile and redo log information

  • Datafile copy information

  • The current log sequence number

  • Checkpoint information

The database name and timestamp originate at database creation. The database name is taken from either the name specified by the DB_NAME initialization parameter or the name used in the CREATE DATABASE statement.

Each time that a datafile or a redo log file is added to, renamed in, or dropped from the database, the control file is updated to reflect this physical structure change. These changes are recorded so that:

  • Oracle can identify the datafiles and redo log files to open during database startup

  • Oracle can identify files that are required or available in case database recovery is necessary

Therefore, if you make a change to the physical structure of your database (using ALTER DATABASE statements), then you should immediately make a backup of your control file.

Control files also record information about checkpoints. Every three seconds, the checkpoint process (CKPT) records information in the control file about the checkpoint position in the redo log. This information is used during database recovery to tell Oracle that all redo entries recorded before this point in the redo log group are not necessary for database recovery; they were already written to the datafiles.

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

相關文章