免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1754 | 回复: 5
打印 上一主题 下一主题

[新手入门] 请教各位老大:什么是裸设备? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-09-09 11:40 |只看该作者 |倒序浏览
请问裸设备是什么概念?是不是指/dev下的设备?
裸设备的作用是什么?是不是要和相应的逻辑卷对应啊?
谢谢!!

论坛徽章:
0
2 [报告]
发表于 2003-09-09 11:49 |只看该作者

请教各位老大:什么是裸设备?

oracle与raw device问答:
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到不同的磁盘上

论坛徽章:
0
3 [报告]
发表于 2003-09-09 13:14 |只看该作者

请教各位老大:什么是裸设备?

论坛徽章:
0
4 [报告]
发表于 2003-09-09 13:15 |只看该作者

请教各位老大:什么是裸设备?

说得简单明了。

论坛徽章:
0
5 [报告]
发表于 2003-09-09 20:01 |只看该作者

请教各位老大:什么是裸设备?

经典的文章总是时时出现,建议放到精品区共享

论坛徽章:
0
6 [报告]
发表于 2003-09-09 21:43 |只看该作者

请教各位老大:什么是裸设备?

正好昨天看到该文的英文版(可能是原版吧),与上面的中文版本不是完全对应的,大家参考对比着看吧

Raw Devices and Oracle - 20 Common Questions and Answers
--------------------------------------------------------
1. What is a raw device?
   A raw device, also known as a raw partition, is a disk partition that is not mounted and written to via the UNIX filesystem, but is accessed via a character-special device driver. It is up to the application how the data is written since there is no filesystem to do this on the application's behalf.
2. How can a raw device be recognised?
   In the '/dev' directory, there are essentially two type of files: block special and character special. Block special files are used when data is transferred to or from a device in fixed size amounts (blocks), whereas character special files are used when data is transferred in varying size amounts. Raw devices use character special files; a long listing    of the '/dev' directory shows them with a 'c' at the leftmost position of the permissions field, e.g.
   crw-rw-rw- 1 root system 15, 0 Mar 12 09:45 rfd0

   In addition, character special files usually have names beginning with an 'r', as shown in the above example. Some devices, principally disks, have both a block special device and a character special device associated with them; for the floppy diskette shown above, there is also a device

   brw-rw-rw- 1 root system 15, 0 Apr 16 15:42 /dev/fd0
      
   So the presence of a 'c' in a device does NOT necessarily mean this is a raw device suitable for use by Oracle (or another application). Generally, a raw device needs to be created and set aside for Oracle (or whatever application is going to use it) when the UNIX system is set up - therefore, this needs to be done with close cooperation between the DBA and UNIX system administrator.
   Once a raw device is in use by Oracle, it must be owned by the oracle account, and may be identified in this way.
3. What are the benefits of raw devices?
       There can be a performance benefit from using raw devices, since a write to a raw device bypasses the UNIX buffer cache, the data is transferred directly from the Oracle buffer cache to the disk. This is not guaranteed,though. If there is no I/O bottleneck, raw devices will not help. The performance benefit if there is a bottleneck can vary between a few percent to something like 40%. Note that the overall amount of I/O is not reduced; it is just done more efficiently.

   Another lesser benefit of raw devices is that no filesystem overhead is incurred in terms of inode allocation and maintenance or free block allocation and maintenance.
4. How can I tell if I will benefit from using raw devices?
   There are two distinct parts to this: first, the Oracle database and application should be examined and tuned as necessary, using one or both of the following:

   -UTLBstat and UTLestat utilities (in $ORACLE_HOME/rdbms/admin)
     
   There are several strategies for improving performance with an existing disk arrangement, i.e. purely within Oracle. See [NOTE:16347.1] for details.

   After checking your Oracle database and application, the next stage is to identify UNIX-level I/O bottlenecks. This can be done using a UNIX utility such as 'sar' or 'vmstat'. See the relevant manual pages for details.
   If you identify that there is a UNIX-level problem with I/O, now is the
   time to start using raw devices. This may well require reorganisation of
   the entire UNIX system (assuming there are no spare partitions
   available).
5. Are there circumstances when raw devices have to be used?
   Yes. If you are using the Oracle Parallel Server, all data files, control files, and redo log files must be placed on raw partitions so they can be shared between nodes. This is a limitation with the UNIX operating system. Also, if you wish to use List I/O or Asynchronous I/O, some versions of UNIX require the data files and control files to be on    raw devices for this to work. Consult your platform-specific documentation for details.

6. Can I use the entire raw partition for Oracle?
   No. You should specify a tablespace slightly smaller in size than the raw partition size, specifically at least two Oracle block sizes smaller.

7. Can I use the first partition of a disk for a raw device?
   This is not recommended. On older versions of UNIX, the first partition contained such information as the disk partition table or logical volume control information, which if overwritten could render the disk useless.
   More recent UNIX versions do not have this problem as disk management is done in a more sophisticated manner. Consult your operating system vendor for more details, but if in any doubt do not use the first partition.
     
8. Who should own the raw device?
   You will need to create the raw devices as root, but the ownership should be changed to the 'oracle' account afterwards. The group must also be changed to the 'dba' group (usually called dba).

9. How do I specify a raw device in Oracle commands?
   When using a raw device you need to specify the full pathname in single quotes, and use the REUSE parameter. e.g. if there are two raw devices, each 30Mb in size, and the database has a 4K block size, the relevant command would look like this:

   create tablespace raw_tabspace datafile '/dev/raw1' size 30712K REUSE                                datafile '/dev/raw2' size 30712K REUSE
10. Does the Oracle block size have any relevance on a raw device?
       It is of less importance than for a UNIX file; the size of the Oracle block can be changed, but it must be a multiple of the physical block  size as it is only possible to seek to physical block boundaries and hence write only in multiples of the physical block size.

11. How can I back up my database files if they are on raw devices?
    You cannot use utilities such as 'tar' or 'cpio', which expect a filesystem to be present. You must use the 'dd' command, as follows:
    dd if=/dev/raw1 of=/dev/rmt0 bs=16k

    See the UNIX man page on dd for further details.

    It is also possible to copy the raw device file (using dd) to a normal UNIX file, and then use a utility such as 'tar' or 'cpio', but this
    requires more disk space and has a greater administrative overhead.

12. Providing I am not using Parallel Server, can I use a mixture of raw partitions and filesystem files for my tablespace locations?

    Yes. The drawback is that this makes your backup strategy more complicated.
        
13. Should I store my redo log files on raw partitions?
    Redo logs are particularly suitable candidates for being located on raw partitions, as they are write-intensive and in addition are written to sequentially. If Parallel Server is being used, redo logs must be stored on raw partitions.

14. Can I use raw partitions for archive logs?
    No. Archive logs must be stored on a partition with a UNIX filesystem.

15. Can I have more than one data file on a raw partition?

    No. This means you should be careful when setting up the raw partition. Too small a size will necessitate reorganisation when you run out of space, whereas too large a size will waste any space the file does not use.

16. Should my raw partitions be on the same disk device?
    This is inadvisable, as there is likely to be contention. You should place raw devices on different disks, which should also be on different controllers.

17. Do I need to make my raw partitions all the same size?
    This is not essential, but it provides flexibility in the event of having to change the database configuration.

18. Do I need to change any UNIX kernel parameters if I decide to use raw devices?
    No, but you may wish to reduce the size of the UNIX buffer cache if no other applications are using the machine.

19. What other UNIX-level changes could help to improve I/O performance?
    RAID and disk mirroring can be beneficial, depending on the application  characteristics, especially whether it is read or write-intensive, or a mixture.

20. How can I gain further performance benefits, after considering all of the
    above?
    You will need to buy more disk drives and controllers for your system, to spread the I/O load between devices.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP