楼主: foxmile

[原创] 关于oracle数据块和操作系统块的关系。

[复制链接]
论坛徽章:
0
11#
发表于 2008-11-5 14:15 | 只看该作者
原帖由 Yong Huang 于 2008-11-4 22:17 发表
This is a frequently asked question. First we need to make a distintion between OS space allocation block size (i.e. sector size, 512 bytes on most platforms) and I/O chunk size. Neverwinter_Newman may be describing the allocation block size. But what's relevant to Oracle performance is I/O chunk size, except for redo log writing, which matches allocation block size. You find the I/O chunk size by doing some I/O and watch sar /b output. Not sure what tool you can use on Windows. But you can always use Oracle's db file scan wait trace file to find Oracle's negotiated chunk size with OS.

I think it's possible you create a database with smaller db_block_size than the OS I/O chunk size. But if you do that, I/O would be bad because you ask for 2 I/O's and the OS has to do two I/O's while it actually CAN do the same work in one. So always use a bigger or the same-size db_block_size as OS I/O chunk size.

Since Oracle redo writing uses chunk size of 512 bytes (or 1k on HPUX and a few other OS'es), it's always better to place redo logfiles on raw partitions or equivalent (Veritas Quick I/O, Oracle ASM etc), bypassing filesystems.

Yong Huang



呵呵!Yong Huang斑竹已经讲的很详细清楚了.

使用道具 举报

回复
论坛徽章:
8
2009新春纪念徽章
日期:2009-01-04 14:52:28祖国60周年纪念徽章
日期:2009-10-09 08:28:002010新春纪念徽章
日期:2010-03-01 11:07:24ITPUB9周年纪念徽章
日期:2010-10-08 09:32:25ITPUB十周年纪念徽章
日期:2011-11-01 16:23:262013年新春福章
日期:2013-02-25 14:51:24沸羊羊
日期:2015-03-04 14:51:522015年新春福章
日期:2015-03-06 11:57:31
12#
发表于 2008-11-5 17:48 | 只看该作者
通常来讲,OS块就是指YONGHUANG文中的I/O chunk size,而他说的OS space allocation block size 就是指扇区,这个扇区在各种操作系统下似乎是一样的,都是512bytes,大家可以想想OS中的低格和高格,当然这是在WINDOWS下,换成其他操作系统名称就不一样了。

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
13#
发表于 2008-11-6 10:22 | 只看该作者
原帖由 foxmile 于 2008-11-4 19:02 发表
...
我是当时在验证这个问题的时候,在一个8k数据库块的数据库上面启用了2k的数据库块,也就是说,在这种情况下,启用这个数据库块和8k的I/O读取并没有太大的区别,只是操作系统做了一些无用功,导致系统性能下降了。
...
上面这句算是redo需要和其他文件分离的一个主要原因吧?
...
你理解文档上说的数据库块是操作系统块的整数倍,是说的OS space allocation block size不是?


Yes and Yes to the first two paragraphs.

Somewhere in documentation there's probably a suggestion that for performance reason, you should create a database with db_block_size equal to one or multiple OS block sizes. It's a suggestion, and I believe the OS block size here refers to I/O chunk size. If it were space allocation block size, that sentence would be meaningless, because as far as I know, space allocation block size is either 512 bytes or 1k depending on OS'es, and since Oracle can only create 2k or its multiple as db_block_size, it always satisfies the "requirement" or "suggestion", so the "requirement" or "suggestion" would be meaningless.

Yong Huang

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
14#
发表于 2008-11-6 10:31 | 只看该作者

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
25
生肖徽章2007版:龙
日期:2008-05-06 11:07:48咸鸭蛋
日期:2011-10-19 10:09:12ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-01-04 11:49:542013年新春福章
日期:2013-02-25 14:51:24
15#
 楼主| 发表于 2008-11-6 14:19 | 只看该作者
原帖由 Yong Huang 于 2008-11-6 10:22 发表


Yes and Yes to the first two paragraphs.

Somewhere in documentation there's probably a suggestion that for performance reason, you should create a database with db_block_size equal to one or multiple OS block sizes. It's a suggestion, and I believe the OS block size here refers to I/O chunk size. If it were space allocation block size, that sentence would be meaningless, because as far as I know, space allocation block size is either 512 bytes or 1k depending on OS'es, and since Oracle can only create 2k or its multiple as db_block_size, it always satisfies the "requirement" or "suggestion", so the "requirement" or "suggestion" would be meaningless.

Yong Huang


嗯,我明白了。也就是说,文档里面只是建议是I/O chunk size的倍数,至少是相当,而意思并不是说必须的。
数据库块小于I/O chunk size并不是不允许的,只是性能不好。

Yong Huang,想再确认一下,数据库在读取数据的时候,顺序是什么?或者说,首先读取数据库文件中的块,然后读操作系统的块?还是其他的过程。

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
25
生肖徽章2007版:龙
日期:2008-05-06 11:07:48咸鸭蛋
日期:2011-10-19 10:09:12ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-01-04 11:49:542013年新春福章
日期:2013-02-25 14:51:24
16#
 楼主| 发表于 2008-11-6 14:23 | 只看该作者
原帖由 Yong Huang 于 2008-11-6 10:31 发表
Also see
http://yong321.freeshell.org/oranotes/FilesystemBlockSize.txt

Yong Huang

多谢Yong Huang。

fox

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
25
生肖徽章2007版:龙
日期:2008-05-06 11:07:48咸鸭蛋
日期:2011-10-19 10:09:12ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-01-04 11:49:542013年新春福章
日期:2013-02-25 14:51:24
17#
 楼主| 发表于 2008-11-6 14:23 | 只看该作者
原帖由 sqysl 于 2008-11-5 17:48 发表
通常来讲,OS块就是指YONGHUANG文中的I/O chunk size,而他说的OS space allocation block size 就是指扇区,这个扇区在各种操作系统下似乎是一样的,都是512bytes,大家可以想想OS中的低格和高格,当然这是在WINDOWS下,换成其他操作系统名称就不一样了。

嗯。我明白了。多谢。

使用道具 举报

回复
论坛徽章:
38
2010新春纪念徽章
日期:2010-01-04 08:33:082012新春纪念徽章
日期:2012-02-13 15:12:252012新春纪念徽章
日期:2012-02-13 15:12:252012新春纪念徽章
日期:2012-02-13 15:12:252012新春纪念徽章
日期:2012-02-13 15:12:252012新春纪念徽章
日期:2012-02-13 15:12:25版主2段
日期:2012-05-15 15:24:11优秀写手
日期:2013-12-18 09:29:08马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
18#
发表于 2008-11-6 21:50 | 只看该作者
原帖由 foxmile 于 2008-11-6 14:19 发表


嗯,我明白了。也就是说,文档里面只是建议是I/O chunk size的倍数,至少是相当,而意思并不是说必须的。
数据库块小于I/O chunk size并不是不允许的,只是性能不好。

Yong Huang,想再确认一下,数据库在读取数据的时候,顺序是什么?或者说,首先读取数据库文件中的块,然后读操作系统的块?还是其他的过程。


用户读段。
服务器进程根据段读相应的Oracle块,它会调用Oracle I/O引擎。
I/O引擎向操作系统请求读操作系统块。
操作系统陷入内核读取操作系统块的所有扇区。

一个操作系统块所有扇区是连续的。
数据块中的多个操作系统块也是连续的。
区中的多个块也是连续的。

大概就这么多吧,这些没仔细研究过,说错的地方大家纠正下。

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
19#
发表于 2008-11-7 02:59 | 只看该作者
原帖由 晶晶小妹 于 2008-11-6 07:50 发表
用户读段。
服务器进程根据段读相应的Oracle块,它会调用Oracle I/O引擎。
I/O引擎向操作系统请求读操作系统块。
操作系统陷入内核读取操作系统块的所有扇区。


Perfect. I hope foxmile is happy with this answer.

Yong Huang

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
25
生肖徽章2007版:龙
日期:2008-05-06 11:07:48咸鸭蛋
日期:2011-10-19 10:09:12ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-01-04 11:49:542013年新春福章
日期:2013-02-25 14:51:24
20#
 楼主| 发表于 2008-11-7 10:47 | 只看该作者
原帖由 晶晶小妹 于 2008-11-6 21:50 发表


用户读段。
服务器进程根据段读相应的Oracle块,它会调用Oracle I/O引擎。
I/O引擎向操作系统请求读操作系统块。
操作系统陷入内核读取操作系统块的所有扇区。

一个操作系统块所有扇区是连续的。
数据块中的多个操作系统块也是连续的。
区中的多个块也是连续的。

大概就这么多吧,这些没仔细研究过,说错的地方大家纠正下。


我贪心一点,再问一下,如果说存储坏了,那实际上,是在I/O引擎请求操作系统块的就报错了,然后直接返回。是不是这样?

块的损坏,应该是分两种层面的,因为在我最近碰到的一个案例中,我们就无法确认,到底块损坏是操作系统级别的还是数据库级别的,在不shutdown immediate 数据库,不重启操作系统的的情况,能否判断呢?

如果是操作系统级别的,我能理解,盘阵或者是存储出了硬件,除此之外,操作系统级别的块损坏还有没有其他原因?

如果是数据库级别的,那这种块损坏有哪些原因呢?逻辑上的?

如果出现了扇区和数据库区的交叉,就是说,一个区访问了多个扇区。是否会导致性能下降。这种性能下降,有没有解决的办法。

[ 本帖最后由 foxmile 于 2008-11-7 10:55 编辑 ]

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表