oracle controlfile structure

介绍下oracle控制文件,控制文件是一个小的二进制文件,只与一个oracle数据库关联,控制文件的备份和恢复这里就先不介绍了,控制文件由很多组件组成,具体可以查看V$CONTROLFILE_RECORD_SECTION<wbr style=""><div style=""> <div style="line-height:25px"><img alt="oracle controlfile structure - dazuiba_008 - 魂醉的一亩二分地" src="http://img2.ph.126.net/ZSk3Msru52c4LKeylM2Byw==/6597594233703871064.png" style="line-height:25px; border-right-width:0px; margin:0px 10px 0px 0px; max-width:100%; border-top-width:0px; border-bottom-width:0px; border-left-width:0px"></div> <div style="line-height:25px"> <div style="line-height:25px">SQL&gt; select sum(record_size*records_total) from v$controlfile_record_section;</div> <div style="line-height:25px"><br style="line-height:25px"></div> <div style="line-height:25px"> 7007244</div> </div> <div style="line-height:25px">可以看到组件合计为7007244bytes</div> <div style="line-height:25px"> <div style="line-height:25px">SQL&gt; ! du -sh /database/oradata/skyread/control01.ctl</div> <div style="line-height:25px">14M /database/oradata/skyread/control01.ctl ------实际控制文件大小</div> </div> <div style="line-height:25px"> <div style="line-height:25px">oracle@readerlogdb-&gt; dbfsize /database/oradata/skyread/control01.ctl</div> <div style="line-height:25px"><br style="line-height:25px"></div> <div style="line-height:25px">Database file: /database/oradata/skyread/control01.ctl</div> <div style="line-height:25px">Database file type: file system</div> <div style="line-height:25px">Database file size: 886 16384 byte blocks --这里控制文件块是16K</div> </div> <div style="line-height:25px"><br style="line-height:25px"></div> <div style="line-height:25px"> <div style="line-height:25px">SQL&gt; ! dbfsize /database/oradata/skyread/system01.dbf</div> <div style="line-height:25px"><br style="line-height:25px"></div> <div style="line-height:25px">Database file: /database/oradata/skyread/system01.dbf</div> <div style="line-height:25px">Database file type: file system</div> <div style="line-height:25px">Database file size: 153600 8192 byte blocks --数据文件块为8K</div> </div> <div style="line-height:25px"><br style="line-height:25px"></div> <div style="line-height:25px">可以看出控制文件块是数据文件块的2倍大小,其实是控制文件块用两个相同的块组成了一个逻辑块</div> <div style="line-height:25px">这里还要注意到并不是所有组件都会有镜像,所以控制文件的大小并不是组件所占空间的2倍大小</div> <div style="line-height:25px">看一下准确算法:</div> <div style="line-height:25px"> <div style="line-height:25px">SQL&gt; select (8*1024)*(1+2*sum(ceil(record_size*records_total/(8*1024)))) bytes from v$controlfile_record_section;</div> <div style="line-height:25px"><br style="line-height:25px"></div> <div style="line-height:25px"> 14180352 ---这个就是实际的控制文件大小</div> </div> <div style="line-height:25px"><strong style="line-height:25px">控制文件包含的内容:</strong></div> <div style="line-height:25px"> <div style="line-height:25px">数据库名 </div> <div style="line-height:25px">创建数据库时的时间戳 </div> <div style="line-height:25px">表空间名 </div> <div style="line-height:25px">物理结构,包括日志文件,</div> <div style="line-height:25px">当前日志的序列号 </div> <div style="line-height:25px">检查点信息 </div> <div style="line-height:25px">回滚段的信息 </div> <div style="line-height:25px">日志归档的历史 </div> <div style="line-height:25px">备份与恢复的信息</div> </div> <div style="line-height:25px"><br style="line-height:25px"></div> <div style="line-height:25px">控制文件出了块级的镜像,还有文件级的镜像,所以每个控制文件时一样的</div> <div style="line-height:25px">参阅:http://www.ixora.com.au/notes/controlfile_structure.htm</div> <div style="line-height:25px">The first block of the controlfile is a header block that records just the controlfile block size and the number of blocks in the controlfile. The controlfile block size is the same as the database block size. When mounting a database, Oracle checks that the controlfile block size and the file size recorded in the controlfile header block match the<span></span><em style="line-height:25px">db_block_size</em><span></span>parameter and the file size reported by the operating system (if available). Otherwise an error is raised to indicate that the controlfile might have been corrupted or truncated. <p style="padding-bottom:0px; line-height:25px; margin:0px 0px 10px; padding-left:0px; padding-right:0px; padding-top:0px"> <span style="color:#ff0000; line-height:25px">After the header block, all controlfile blocks occur in pairs. Each logical block is represented by two physical blocks. This is necessary for the<span></span><a href="http://www.ixora.com.au/notes/controlfile_transactions.htm" rel="nofollow" style="line-height:25px; color:rgb(185,0,0); text-decoration:none">controlfile transaction</a><span></span>mechanism.</span></p> <p style="padding-bottom:0px; line-height:25px; margin:0px 0px 10px; padding-left:0px; padding-right:0px; padding-top:0px"> It is theoretically possible that a hot backup of a controlfile could contain a split block. Therefore all controlfile blocks other than the file header have a<span></span><a href="http://www.ixora.com.au/notes/cache_header.htm" rel="nofollow" style="line-height:25px; color:rgb(185,0,0); text-decoration:none">cache header and tail</a><span></span>that can be compared when mounting a database and whenever a controlfile block is read. The block type is 0 for virgin controlfile blocks and 21 otherwise. The physical controlfile block number is used in place of an RDBA in the cache header, and a<span></span><a href="http://www.ixora.com.au/notes/controlfile_transactions.htm#controlfile_sequence_number" rel="nofollow" style="line-height:25px; color:rgb(185,0,0); text-decoration:none">controlfile sequence number</a><span></span>is used in place of an SCN to record when the block was last changed. An ORA-00227 error is returned if the header and tail do not match, or if the block checksum does not match the checksum recorded in the cache header (if any).</p> <p style="padding-bottom:0px; line-height:25px; margin:0px 0px 10px; padding-left:0px; padding-right:0px; padding-top:0px"> The controlfile contains several different types of records, each in its own record section of one or more logical blocks. Records may span block boundaries within their section. The fixed view V$CONTROLFILE_RECORD_SECTION lists the types of records stored in each record section, together with the size of the record type, and the number of record slots available and in use within that section. The underlying X$KCCRS structure includes the starting logical block number (RSLBN) for each section.</p> </div> </div> </wbr>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值