什么是裸设备?Oracle为什么要选用裸设备?
裸设备,也叫裸分区(原始分区),是一种没有经过格式化,不被Unix通过文件系统来读取的特殊字符设备。本文收集裸设备和Oracle问答20例。
1.什么叫做裸设备?
裸设备,也叫裸分区(原始分区),是一种没有经过格式化,不被Unix通过文件系统来读取的特殊字符设备。它由应用程序负责对它进行读写操作。不经过文件系统的缓冲。
2.如何辨别裸设备?
在Unix的/dev 目录下,有许多文件,其中有两个大类:字符设备文件和块设备文件。
字符设备特殊文件进行I/O操作不经过操作系统的缓冲区,而块设备特殊文件用来同外设进行定长的包传输。字符特殊文件与外设进行I/o操作时每次只传输一个字符。而对于块设备特殊文件来说,它用了cache机制,在外设和内存之间一次可以传送一整块数据。裸设备使用字符特殊文件。在/dev 目录下,你可以看到许多这样的文件。
3.使用裸设备的好处
因为使用裸设备避免了再经过Unix操作系统这一层,数据直接从Disk到Oracle进行传输,所以使用裸设备对于读写频繁的数据库应用来说,可以极大地提高数据库系统的性能。当然,这是以磁盘的 I/O 非常大,磁盘I/O已经称为系统瓶颈的情况下才成立。如果磁盘读写确实非常频繁,以至于磁盘读写成为系统瓶颈的情况成立,那么采用裸设备确实可以大大提高性能,最大甚至可以提高至40%,非常明显。
而且,由于使用的是原始分区,没有采用文件系统的管理方式,对于Unix维护文件系统的开销也都没有了,比如不用再维护I-node,空闲块等,这也能够导致性能的提高。
4.如何决定是否应该使用裸设备?
判断是否使用裸设备要从以下方面进行考虑:首先,数据库系统本身需要已经被比较好的经过了优化。优化是一门很有些技术的话题,很难简单地讲述。其次,使用Unix命令来辨别是否存在磁盘读写瓶颈。比如Unix的vmstat, sar 等命令都可以较好的进行鉴别。如果决定采用裸设备,需要磁盘上还有空闲的分区。否则,就要新添磁盘,或者对原有系统重新规划。
5.什么系统必须使用裸设备?
如果使用了Oracle 并行服务器选项,则必须采用裸设备来存放所有的数据文件,控制文件,重做日志文件。只有把这些文件放到裸设备上,才能保证所有Oracle 实例都可以读取这个数据库的文件。这是由Unix操作系统的特性决定的。
还有一种情况是,如果你想使用异步I/O,那么在有些Unix上也必须采用裸设备。这个需要参考具体Unix的相关文档。
6.能够使用一个磁盘的第一个分区作为裸设备吗?
可以,但是不推荐。在Unix的比较旧的版本是银行,磁盘的第一个分区常常包含这个磁盘的一些信息,以及逻辑卷的一些控制信息。若这些部分被裸设备覆盖的话,磁盘就会变得不可识别,导致系统崩溃。
较新的Unix版本不会发生这样的情况,因为它们采用了更复杂的技术来管理磁盘,逻辑卷的一些信息。
但是,除非很确信不要使用磁盘的第一个分区来作为裸设备。
7.我可以把整个裸设备都作为Oracle的数据文件吗?
不行。必须让数据文件的大小稍微小于该裸设备的实际大小。至少要空出两个oracle块的大小来。
8.裸设备应该属于那个用户?
应该由root来创建裸设备,然后再分配给Oracle用户以供使用。同时还要把它归入Oracle用户所在的那个组里边(通常都是DBA)。
9.在创建数据文件时如何指定裸设备?
和普通文件没有什么太大的区别,一样都是在单引号里边写上裸设备的详细路径就可以了。举一个例子:要在创建一个表空间,使用两个裸设备,每个分别为30M的大小,Oracle块的大小为4K,可以用下面的命令:
CREATE TABLESPACE RAW_TS
DATAFILE ’/dev/raw1′ size 30712k
DATAFILE ’/dev/raw2′ size 30712k;
10.Oracle块的大小和裸设备有什么关系吗?
Oracle会必须是裸设备上物理块大小的倍数。
11.如何在裸设备上进行备份?
在裸设备上,不能使用Unix实用程序来进行备份,唯一的办法是使用最基本的Unix命令:DD来进行备份。比如:dd if=/dev/raw1 of=/dev/rmt0 bs=16k。dd的具体语法可以参考unix手册,或者联机帮助。你也可以先用dd把裸设备上的数据文件备份到磁盘上,然后再利用Unix实用程序进一步处理。
12.如果我没有使用Oracle并行服务器选项,我可以在数据库上让一部分数据文件使用文件系统,另一部分使用裸设备吗?
可以。但是这样的话,会使备份过程更加复杂。
13.我应该把联机重做日志文件放到裸设备上吗?
这是一个极好的选择。联机重做日志文件是写操作非常频繁的文件,放到裸设备上非常合适。如果你使用了并行服务器选项,那么联机重做日志文件必须放到裸设备上面。
14.可以把归档日志文件放到裸设备上吗?
不行。归档日志文件必须放到常规的Unix文件系统上面,或者直接放到磁带上面去。
15.我可以在裸设备上边放置多个数据文件吗?
不行。所以你必须在设置裸设备时非常小心。太小的话,会导致空间很快用完,太大的话,空间就白白浪费了。
16.因应该把几个裸设备放到同一个物理磁盘上吗?
这样做不好。因为使用裸设备就是为了提高磁盘读写速度。而把多个裸设备放到同一个物理磁盘上会导致读写竞争,这样对于提高I/O速度是不利的。应该尽量分散裸设备到不同的物理磁盘上,最好是分散到不同的磁盘控制器上。这是最佳选择。
17.需要把所有裸设备都定义成同样的大小吗?
这不是必须得,但是划分成同样的大小对于管理数据库比较有利。
18.为了在Unix上使用裸设备,我需要改变Unix核心参数吗?
不需要。但可以选择减小缓冲区的大小,如果没有别的应用也在同一台Unix机器上运行。因为运用了裸设备以后,不再使用Unix的系统缓冲区。
19.为了提高读写速度,在操作系统级别上,还有什么办法可以采取吗?
使用RAID(廉价冗余磁盘阵列)也是非常有效的办法,尤其实那种读写非常频繁的系统。
20.在考虑了以上所有方面后,还能有什么办法可以提高性能的吗?
这就需要对Oracle 进行优化,并且购买更多的磁盘和磁盘控制器,来分散I/O到不同的磁盘上。
————————-
虽然ORACLE的文档说裸设备可以大幅度提高数据库性能.但是根据实际使用经验,不同的操作系统差别很大.如果文件系统本来效率非常高(EXT3),那么使用裸设备几乎不能提高数据库性能(做过实际测试,几乎提高不到3%).但是随之带来的数据文件备份问题却非常麻烦.所以我个人的看法是,除了使用集群或者是其他特别的原因,不要使用裸设备.性能的提高完全被数据库的维护消耗,而且是负增长.
————————-
裸设备还有一个重要的优势是数据的一致性,因为隔着文件系统oracle不能确保数据写入了硬盘,尤其是非日志型的文件系统。
关于性能,裸设备也不一定会有提高。一般是io的量越大越有效果。
裸设备能不能提高性能,关键在于i/o到底是不是你的系统的瓶颈,如果i/o负荷很小,当然就没有用处了!
———————–
裸设备就是绕过文件系统直接访问的储存空间。
———————–
磁盘I/O是影响Oracle数据库性能的一个重要原因。就本质来说,任何Oracle数据库负责存储数据,从磁盘中查询数据是非常昂贵和费时的操作。
由于许多Oracle系统需要大量的I/O操作,很多Oracle专职人员在碰到大块(DB_BLOCK_SIZE)数据操作时就考虑使用“裸设备”(raw device)。裸设备指得是绕过UNIX 的Journal文件系统(Journal File System ,JFS)直接进行访问的磁盘,这样就省去了JFS文件系统的开销。
磁盘I/O开销的减少可以提高磁盘吞吐量,但是只有在I/O操作确实已经是影响Oracle数据库性能提高的瓶颈的情况下才是这样的。此外,使用裸设备还要求Oracle管理员和系统管理员进行大量的手工劳动。
Oracle建议只有在Oracle数据库性能受到I/O速度限制时才需要考虑使用原始设备,这一点非常重要。对这样的Oracle数据库来说,裸设备可以极大的提高总体性能。但是如果数据库性能没有受I/O速度的制约,使用裸设备并不会对性能提高有所帮助。
还有一点需要说明,在Oracle 8.1.7中,这个特性称之为Direct I/O,某些高端的UNIX平台支持该特性。Veritas公司也销售一个名为Quick I/O的产品,它为Oracle提供了接近于裸设备的性能而无需额外的管理裸设备所需的开销。
——————-
建立在裸设备上的文件系统是无法通过操作系统的文件系统来访问的。
——————-
裸设备是由oracle建立的还是由unix建立的?
当然是unix建立的,至于裸设备与磁盘的对应关系,当然可以是一对一,多对一,一对多了,裸设备就是aix中的lv.。
From OracleOnLinux, post 什么是裸设备?Oracle为什么要选用裸设备?
Categories:
Tags:
Very useful informations about these subject. I have found them with googling and you seems number one of these subjects ! . . .
Educational and entertaining. I’ve additional your internet log to my “reading substance. ” Progress me updated!. . . .
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.
I agree with you. This type of projects should be encouraged and I think that these type of projects are the projects for the future. . . . .
I tried to subscribe to your rss feed, but had a problem adding it to google reader. Could you please check this out.
This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It?s the old what goes around comes around routine. Did you acquired lots of links and I see lots of trackbacks??
Hey – nice blog, just looking around some blogs, seems a pretty nice platform you are using. I’m currently using Wordpress for a few of my sites but looking to change one of them over to a platform similar to yours as a trial run. Anything in particular you would recommend about it?
Easily, the article is actually the best topic on this registry related issue. I fit in with your conclusions and will eagerly look forward to your next updates. Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates.
Very useful informations about these subject. I have found them with googling and you seems number one of these subjects ! . . .
Hey Boss – its a nice blog, just looking around some blogs, seems a pretty nice platform you are using. I’m currently using Wordpress for a few of my sites but looking to change one of them over to a platform similar to yours as a trial run. Anything in particular you would recommend me about it?
I tried to subscribe to your rss feed, but had a problem adding it to google reader. Could you please check this out.
Its very informative and interesting article.all the points are very useful. Simple but very effective writing. Thanks for sharing such a nice post.
I love reading and I am always searching for informative information like this! You are bookmarked!. . . . . .
Considerably, the blog post is actually the greatest on this worthy topic. I concur with your decisions and will thirstily look forward to see your approaching updates. Saying thanks will not just be adequate, for the phenomenal lucidity in your writing. I will at once grab your feeds to stay informed of any updates. Delightful work and much success in your business endeavors! Have a nice day
Advantageously, the post is in reality the freshest topic on curing acne naturally. I concur with your conclusions and will thirstily look forward to your upcoming updates. Just saying thanks will not just be enough, for the phenomenal clarity in your writing. I will right away grab your rss feed to stay abreast of any updates.
Aw, this was a really quality post. In theory I’d like to write like this too – taking time and real effort to make a good article… but what can I say… I procrastinate alot and never seem to get something done.
You really make it seem so easy with your presentation but I find this topic to be really something which I think I would never understand. It seems too complicated and very broad for me. I am looking forward for your next post.
Thank you very much this is a very nice information!. . . . . .
I am really thankful to the author of this post for making this lovely and informative article live here for us. We really appreciate ur effort. Keep up the good work. . . .
That is very inspirational stuff. Never known that feeling can be this diversified. Thanks for all the enthusiasm to extend such helpful information on this post. . . .
The author of this article should be immensely proud. I do like to reckon myself to possess a keen eye for writing, and posts such as this truly do put a smile on my face. Keep it up.
Thanks for writing this info.
Just saved ur site on Delicious and StumbleUpon.I luv readin ur commentaries.