Oracle RAC--在Linux中创建裸设备

      首先解释一下裸设备的概念    裸设备(raw device),也叫裸分区(原始分区),是一种没有经过格式化,不被Linux通过文件系统来读取的特殊块设备文件。它是不被操作系统直接管理的设备,是通过字符方式访问的设备,这种设备少了操作系统这一层,I/O效率更高。不少数据库都能通过使用裸设备作为存储介质来提高I/O效率。  缺点就是不容易被管理。
一:先对磁盘分区
[ root@ENMOEDU ~]# fdisk /dev/sdb                       #对磁盘/dev/sdb   分区
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel 
Building a new DOS disklabel. Changes will remain in memory only, 
until you decide to write them. After that, of course, the previous 
content won't be recoverable. 


The number of cylinders for this disk is set to 2610. 
There is nothing wrong with that, but this is larger than 1024, 
and could in certain setups cause problems with: 
1) software that runs at boot time (e.g., old versions of LILO) 
2) booting and partitioning software from other OSs 
(e.g., DOS FDISK, OS/2 FDISK) 
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) 

Command (m for help): n                         #n 就代表分区
Command action 
e extended 
p primary partition (1-4)  
p                                                                 #p 表示选择主分区,
Partition number (1-4): 1                          #主分区的个数 1     
First cylinder (1-2610, default 1): 1           # 默认从第一个柱面开始   
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):     
Using default value 2610 

Command (m for help): w              #写进磁盘,使分区生效,
The partition table has been altered! 

Calling ioctl() to re-read partition table. 
Syncing disks. 
二:创建裸设备
方法1:目前最常用的方法
[ root@ENMOEDU rules.d]#cd   /etc/udev/rules.d            #配置裸设备的目录                     
[ root@ENMOEDU rules.d]# vi     60-raw.rules       #它里面有例子,两种配置方法, 在里面添加下面红色部分(也就是选择的第二种)
[ root@ENMOEDU rules.d]# cat 60-raw.rules             
# Enter raw device bindings here. 

# An example would be: 
# ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N" 
# to bind /dev/raw/raw1 to /dev/sda, or 
# ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m" 
# to bind /dev/raw/raw2 to the device with major 8, minor 1. 
ACTION=="add", KERNEL=="sdb", RUN+="/bin/raw /dev/raw/raw1  %N" 
方法2:以前红帽4版本  用的的方法
[ root@ENMOEDU rules.d]# raw  /dev/raw/raw1        /dev/sdb1           # 绑定后生成一个文件/dev/raw/raw1 记录绑定的信息.如果不想要直接删除这个文件就行了     重启都就失效        
/dev/raw/raw1: bound to major 8, minor 17
[root@rac2 ~]#vi /etc/sysconfig/rawdevices            --编辑文件,建立映射    重启之后也能保留住raw的信息 
        /dev/raw/raw1  /dev/sdb1 
[ root@ENMOEDU rules.d]# raw   -qa                         #查询裸设备           
/dev/raw/raw1: bound to major 8, minor 17 
[ root@ENMOEDU rules.d]# ls -qlt    /dev/raw/raw1              
crw------- 1 root root 162, 1 Aug 28 20:32 /dev/raw/raw1  
 三:裸设备的使用,可
以直接在把Oracle数据库的表空间建立在裸设备上,来提高读写速度。
SYS@ENMOEDU> create tablespace liuwenhe datafi
le '/dev/raw/raw1' size 50m ; 

Tablespace created. 
总结:裸设备不经过文件系统的缓冲,跨越了操作系统这一层,数据直接从Disk到Oracle进行传输,提高了数据的读写速度,
前提是磁盘的读写确实非常频繁,以至于磁盘读写成为系统瓶颈。不可以把整个裸设备都作为Oracle的数据文件(必须让数据文件的大小稍微小于该裸设备的实际大小)。




















    

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29654823/viewspace-1259820/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29654823/viewspace-1259820/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值