oracle 11g歸檔日誌研究_1

來源:互聯網
上載者:User

標籤:

oracle的資料庫操作都會被記錄在redo log中,用來進行undo(復原)或在資料庫異常的時候redo(重做)。redo log又分為online(線上日誌)和archive(歸檔日誌)兩部分。

oracle預設有3個線上記錄檔,通常它們是按順序寫滿一個再寫下一個,而寫滿的線上記錄檔會被整理為歸檔日誌。在每個線上日誌內部,可能按順序或隨機填寫資料。

 

線上日誌和歸檔日誌一樣,都是由很多塊組成,檔案第1塊作為檔案頭,包含塊大小、塊總數等資訊,第2塊作為資料庫頭,包含資料庫資訊(如版本號碼、資料庫ID、檔案序號等)。預設情況下,塊大小為512bytes,也可能有1k、2k等的情況(我還沒遇到),所以redo log檔案大小一定是512位元組的整數倍。

第1塊的資料格式:

typedef struct fh0 {    uint32_t unknown0;    uint32_t unknown1;    uint32_t unknown2;    uint32_t unknown3;    uint32_t unknown4;    uint32_t blocksize;     //每塊大小(位元組), 512/1024...    uint32_t blockcount;    //當前檔案的總塊數(不包括第一塊)    uint32_t unknown5;    uint8_t nouse[480];}Redo_fh0;
Redo_fh0

 

第2塊的資料格式:

typedef struct scn {    uint32_t scnbase;    uint16_t scnwrapper;    uint16_t filler;}Redo_scn;typedef struct fh1 {    Redo_bh blockhead;    uint32_t unknown0;    uint32_t comvsn;        //Compatibility Vsn    uint32_t dbid;    uint8_t dbname[8];      //"ORCL"(sid)    uint32_t controlseq;    uint32_t filesize;    uint32_t blocksize;    uint16_t filenum;    uint16_t filetype;    uint32_t activid;    uint8_t nouse0[36];     //0    uint8_t descript[64];    uint32_t nab;           //next available block    uint32_t resetcount;    Redo_scn resetscn;    uint32_t hws;           //後3位元組為0    uint32_t thread;    Redo_scn lowscn;    uint32_t lowscntime;    Redo_scn nextscn;    uint32_t nextscntime;    uint32_t unknown11;    Redo_scn enablescn;    uint32_t enablescntime;    Redo_scn thrclosescn;    uint32_t thrclosescntime;    uint8_t unknown13[52];    Redo_scn prevresetscn;    uint32_t prevresetcount;    uint8_t nouse1[152];    //0    uint8_t unknown14[36];    uint8_t nouse2[28];     //0}Redo_fh1;
Redo_fh1

 

第1塊與其他塊完全不同,它不含有塊頭,也不被包含在塊總數之內。從第2塊開始,所有的資料區塊的前16個位元組為塊頭,格式:

typedef struct bh {    uint32_t signature;     //簽名    uint32_t blocknum;      //塊號    uint32_t sequence;      //順序號    uint16_t offset;        //最高位1需過濾掉    uint16_t checksum;}Redo_bh;
Redo_bh

 

下面詳細研究歸檔日誌。

oracle 11g歸檔日誌研究_1

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.