最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識(shí)百科 - 正文

Oracle學(xué)習(xí).數(shù)據(jù)文件、控制文件、重做日志文件的理解

來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-09 15:41:37
文檔

Oracle學(xué)習(xí).數(shù)據(jù)文件、控制文件、重做日志文件的理解

Oracle學(xué)習(xí).數(shù)據(jù)文件、控制文件、重做日志文件的理解:什么是數(shù)據(jù)文件、控制文件、重做日志文件? 首先從Oracle的官方文檔里摘錄下面內(nèi)容: The following divs explain the physical database structures of an Oracle database, including datafiles, redo log files
推薦度:
導(dǎo)讀Oracle學(xué)習(xí).數(shù)據(jù)文件、控制文件、重做日志文件的理解:什么是數(shù)據(jù)文件、控制文件、重做日志文件? 首先從Oracle的官方文檔里摘錄下面內(nèi)容: The following divs explain the physical database structures of an Oracle database, including datafiles, redo log files

什么是數(shù)據(jù)文件、控制文件、重做日志文件? 首先從Oracle的官方文檔里摘錄下面內(nèi)容: The following divs explain the physical database structures of an Oracle database, including datafiles, redo log files, and control files 下面幾段內(nèi)容將解釋一

什么是數(shù)據(jù)文件、控制文件、重做日志文件?


首先從Oracle的官方文檔里摘錄下面內(nèi)容:

The following divs explain the physical database structures of an Oracle database, including datafiles, redo log files, and control files

下面幾段內(nèi)容將解釋一下,Oracle數(shù)據(jù)庫的物理結(jié)構(gòu)是什么?包括數(shù)據(jù)文件、控制文件和重做日志文件。

Datafiles


Every Oracle database has one or more physical datafiles. The datafiles contain all the database data. The data of logical database structures, such as tables and indexes, is physically stored in the datafiles allocated for a database.

The characteristics of datafiles are:

  • A datafile can be associated with only one database.

  • Datafiles can have certain characteristics set to let them automatically extend when the database runs out of space.

  • One or more datafiles form a logical unit of database storage called a tablespace.

  • Data in a datafile is read, as needed, during normal database operation and stored in the memory cache of Oracle. For example, assume that a user wants to access some data in a table of a database. If the requested information is not already in the memory cache for the database, then it is read from the appropriate datafiles and stored in memory.

    Modified or new data is not necessarily written to a datafile immediately. To reduce the amount of disk access and to increase performance, data is pooled in memory and written to the appropriate datafiles all at once, as determined by the database writer process (DBWn) background process.

    數(shù)據(jù)文件:

    每一個(gè)Oracle數(shù)據(jù)庫都要有一個(gè)或者多個(gè)物理的數(shù)據(jù)文件,這些數(shù)據(jù)文件里存儲(chǔ)的就是Oracle數(shù)據(jù)庫里的數(shù)據(jù)。就好比你有一個(gè)文件夾,里面有幾個(gè)txt的文本文件,文本文件里記錄的你這個(gè)月的每一筆花銷。如果把文件夾看做是數(shù)據(jù)庫,那么txt文件就是數(shù)據(jù)文件,而txt文件里面記錄的每一筆花銷就是數(shù)據(jù)了。

    然而表、索引等等其實(shí)都是數(shù)據(jù)庫的邏輯結(jié)構(gòu),這些表、索引都被物理的存儲(chǔ)在了數(shù)據(jù)文件里面。

    數(shù)據(jù)文件有三個(gè)特性:

    1、一個(gè)數(shù)據(jù)文件只能屬于一個(gè)數(shù)據(jù)庫。

    2、數(shù)據(jù)庫中的數(shù)據(jù)文件可以被設(shè)置成自動(dòng)的增長。(當(dāng)數(shù)據(jù)庫的空間用完的時(shí)候,數(shù)據(jù)庫中的數(shù)據(jù)文件就會(huì)自動(dòng)增長,比如原來1G的數(shù)據(jù)文件自動(dòng)變成了2G的數(shù)據(jù)文件)

    3、一個(gè)或者多個(gè)數(shù)據(jù)文件就組成了數(shù)據(jù)庫的一個(gè)邏輯單元叫做---表空間。

    (就比如記錄流水賬,那這個(gè)月的賬目就組成了一個(gè)表空間,下個(gè)月的就是另外一個(gè)表空間。)

    數(shù)據(jù)文件里的數(shù)據(jù),在需要的時(shí)候就會(huì)被讀取到內(nèi)容Oracle的緩沖區(qū)中,比如當(dāng)我們想查看一天數(shù)據(jù)時(shí),而這條數(shù)據(jù)恰好又不在Oracle的緩沖區(qū)中,那么Oracle就會(huì)把這條數(shù)據(jù)從數(shù)據(jù)文件中讀取到Oracle的緩沖區(qū)中來。

    當(dāng)更改或者新增一天數(shù)據(jù)時(shí),也不是馬上就寫到數(shù)據(jù)文件里面,這么做是為了減少對磁盤的訪問,提高效率,數(shù)據(jù)先存儲(chǔ)在緩沖區(qū),然后在一次都寫入數(shù)據(jù)文件,這個(gè)過程有一個(gè)dbwn后臺(tái)進(jìn)程來控制。


    Control Files
     
    Every Oracle database has a control file. A control file contains entries that specify the physical structure of the database. For example, it contains the following information:

    Database name

    Names and locations of datafiles and redo log files

    Time stamp of database creation

    Oracle can multiplex the control file, that is, simultaneously maintain a number of identical control file copies, to protect against a failure involving the control file.

    Every time an instance of an Oracle database is started, its control file identifies the database and redo log files that must be opened for database operation to proceed. If the physical makeup of the database is altered (for example, if a new datafile or redo log file is created), then the control file is automatically modified by Oracle to reflect the change. A control file is also used in database recovery.

    控制文件:

    每一個(gè)數(shù)據(jù)庫都擁有控制文件(它和數(shù)據(jù)文件一樣重要),控制文件里記錄的是對數(shù)據(jù)庫物理結(jié)構(gòu)的詳細(xì)信息,例如它包括如下三個(gè)信息:
    1、數(shù)據(jù)庫的名稱
    2、數(shù)據(jù)文件的名字和存在位置,重做日志文件的名字和存儲(chǔ)位置
    3、數(shù)據(jù)庫創(chuàng)建的時(shí)間標(biāo)識(shí)

    Oracle可以使用多重的控制文件,也就是說它可以同時(shí)維護(hù)多個(gè)完全一樣的控制文件,這么做就是為了防止數(shù)據(jù)文件損壞而造成的數(shù)據(jù)庫故障。比如Oracle同時(shí)維護(hù)3個(gè)控制文件,當(dāng)其中有1個(gè)控制文件出問題了,就比較好解決,把出問題的刪了,在復(fù)制一份沒有問題的就可以了。

    每當(dāng)Oracle數(shù)據(jù)庫的實(shí)例啟動(dòng)的時(shí)候,它就會(huì)通過控制文件來識(shí)別,要想執(zhí)行數(shù)據(jù)庫的一些操作,必須需要哪些數(shù)據(jù)文件和重做日志文件,以及這些數(shù)據(jù)文件和重做日志文件都存在在什么位置。當(dāng)數(shù)據(jù)庫的物理構(gòu)成發(fā)生改變的時(shí)候,比如新增加了一個(gè)數(shù)據(jù)文件或者重做日志文件,那么控制文件就會(huì)自動(dòng)的更新來記錄這些變化。另外在數(shù)據(jù)庫恢復(fù)的時(shí)候也會(huì)用到控制文件。


    Redo Log Files
     
    Every Oracle database has a set of two or more redo log files. The set of redo log files is collectively known as the redo log for the database. A redo log is made up of redo entries (also called redo records).

    The primary function of the redo log is to record all changes made to data. If a failure prevents modified data from being permanently written to the datafiles, then the changes can be obtained from the redo log, so work is never lost.
     
    To protect against a failure involving the redo log itself, Oracle allows a multiplexed redo log so that two or more copies of the redo log can be maintained on different disks.

    The information in a redo log file is used only to recover the database from a system or media failure that prevents database data from being written to the datafiles. For example, if an unexpected power outage terminates database operation, then data in memory cannot be written to the datafiles, and the data is lost. However, lost data can be recovered when the database is opened, after power is restored. By applying the information in the most recent redo log files to the database datafiles, Oracle restores the database to the time at which the power failure occurred.

    The process of applying the redo log during a recovery operation is called rolling forward.

    重做日志文件:
    每個(gè)Oracle數(shù)據(jù)庫都擁有一組文件,其中包括2個(gè)或者多個(gè)重做日志文件(其實(shí)也可以擁有多組,用途跟多個(gè)控制文件一樣)。這組文件整體被稱為數(shù)據(jù)庫的重做日志,而重做日志又是由一條一條的重做記錄組成的,所有也被稱為重做記錄。
    重做日志的主要作用就是記錄所有的數(shù)據(jù)變化,當(dāng)一個(gè)故障導(dǎo)致被修改過的數(shù)據(jù)沒有從內(nèi)存中永久的寫到數(shù)據(jù)文件里,那么數(shù)據(jù)的變化是可以從重做日志中獲得的,從而保證了對數(shù)據(jù)修改的不丟失。
    為了防止重做日志自身的問題導(dǎo)致故障,所以O(shè)racle擁有多重重做日志功能,也就是可以同時(shí)保存多組完全相同的重做日志在不同的磁盤上。
    重做日志里的信息只是用于恢復(fù)由于系統(tǒng)或者介質(zhì)故障所引起的數(shù)據(jù)沒法寫入數(shù)據(jù)文件的數(shù)據(jù)。比如突然斷電導(dǎo)致數(shù)據(jù)庫的關(guān)閉,那么內(nèi)存中的數(shù)據(jù)就不能寫入到數(shù)據(jù)文件中,內(nèi)存中的數(shù)據(jù)就會(huì)丟失。但當(dāng)數(shù)據(jù)庫重新啟動(dòng)時(shí)丟失的數(shù)據(jù)是可以被恢復(fù)的,可以從最近的重做日志中讀取丟失信息然后應(yīng)用到數(shù)據(jù)文件中,這樣就把數(shù)據(jù)庫恢復(fù)到斷電前的狀態(tài)。
    在恢復(fù)操作中恢復(fù)重做日志信息的過程叫做回滾。

    聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    Oracle學(xué)習(xí).數(shù)據(jù)文件、控制文件、重做日志文件的理解

    Oracle學(xué)習(xí).數(shù)據(jù)文件、控制文件、重做日志文件的理解:什么是數(shù)據(jù)文件、控制文件、重做日志文件? 首先從Oracle的官方文檔里摘錄下面內(nèi)容: The following divs explain the physical database structures of an Oracle database, including datafiles, redo log files
    推薦度:
    標(biāo)簽: 控制 文件 數(shù)據(jù)
    • 熱門焦點(diǎn)

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top