裸设备

 

裸设备,也叫裸分区(原始分区),是一种没有经过格式化,不被Unix通过文件系统来读取的非凡字符设备。
它由应用程序负责对它进行读写操作。不经过文件系统的缓冲。

 

我们可以将oracle得表空间直接建立在裸设备上,提高读写速度

create tablespace sale_ts datafile '/dev/raw/raw1'
size 20000m
autoextend on next 100m maxsize unlimited
extent management local
segment space management auto;


1.[root@rac2 ~]#/sbin/fdisk /dev/sdb
50M
ora1,partprobe --立即生效

2.[root@rac2 ~]#vi /etc/sysconfig/rawdevices --编辑文件,建立映射
/dev/raw/raw1 /dev/sdb1
[root@rac2 ~]#/etc/init.d/rawdevices restart --重启服务(redhat 5之前的版本)

or

3.[root@rac2 ~]#raw /dev/raw/raw1 /dev/sdb1
保存在/etc/rc.local中,重启后还会生效

or
4. udev
redhat5:
vi /etc/udev/rules.d/60-raw.rules
ACTION=="add", KERNEL=="sde", RUN+="/bin/raw /dev/raw/raw1 %N"
...
vi /etc/rc.local (修改权限)
reboot


/etc/udev/rules.d/60-raw.rules
添加如下几句,其他的也可以类推
ACTION=="add", KERNEL=="xvdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="xvdb2", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="raw*", WNER=="oracle", GROUP=="oinstall", MODE=="0664"


 


create tablespace sale_ts datafile '/dev/sdb1' size 20m ;

 

只要/dev/raw/raw1,/dev/sdb1是oracle.dba属主,以上写法都可以.

 

SQL> select name from v$datafile
2 union all
3 select name from v$controlfile
4 union all
5 select name from v$tempfile;

NAME
--------------------
/dev/raw/raw8
/dev/raw/raw10
/dev/raw/raw9
/dev/raw/raw12
/dev/raw/raw2
/dev/raw/raw3
/dev/raw/raw4
/dev/raw/raw11

8 rows selected.

SQL> select * from v$logfile;

GROUP# STATUS TYPE MEMBER IS_
---------- ---------- ------- -------------------- ---
3 STALE ONLINE /dev/raw/raw7 NO
2 ONLINE /dev/raw/raw6 NO
1 ONLINE /dev/raw/raw5 NO


SQL> show parameter pfile

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /dev/raw/raw1