虽然在Linux装了很多单机版的Oracle数据库,但是还未直接使用过裸设备作为各种文件的存储方式来安装数据库。下面讨论一下在LInux平台使用裸设备作为存放方式安装数据库。
一.创建物理块分区设备文件
在Linux平台使用传统的fdisk进行分区的话,对分区个数是有限制的,3个主分区和逻辑分区之和最多只能有15个,但在实际的部署中,需要的裸设备个数远远大于这个值。为了能创建更多的裸设备就必须使用到Linux平台的LVM技术,对于一个VG来说,最多可以创建255个LV,也就是说一个VG可以最多有255个裸设备。
服务器包含4张300GB的SAS盘,做成RAID5,在系统上只能看到一个设备/dev/sda,其中/dev/sda1作为/boot,/dev/sda2作为swap,/dev/sda3作为/,/dev/sda4作为LVM的物理卷被使用。执行下面的命令创建物理卷、卷组、逻辑卷:
pvcreate /dev/sda4
vgcreate -s 256M oravg /dev/sda4
vgchange -a y oravg
lvcreate -L 100M -n sglaw_ctl01 oravg
lvcreate -L 100M -n sglaw_ctl02 oravg
lvcreate -L 100M -n sglaw_ctl03 oravg
lvcreate -L 256M -n sglaw_redo01 oravg
lvcreate -L 256M -n sglaw_redo02 oravg
lvcreate -L 256M -n sglaw_redo03 oravg
lvcreate -L 256M -n sglaw_redo04 oravg
lvcreate -L 10G -n sglaw_data01 oravg
lvcreate -L 10G -n sglaw_data02 oravg
lvcreate -L 10G -n sglaw_data03 oravg
lvcreate -L 10G -n sglaw_data04 oravg
lvcreate -L 10G -n sglaw_data05 oravg
lvcreate -L 10G -n sglaw_data06 oravg
lvcreate -L 10G -n sglaw_data07 oravg
lvcreate -L 10G -n sglaw_data08 oravg
lvcreate -L 10G -n sglaw_data09 oravg
lvcreate -L 10G -n sglaw_data10 oravg
lvcreate -L 10G -n sglaw_data11 oravg
lvcreate -L 10G -n sglaw_data12 oravg
lvcreate -L 10G -n sglaw_data13 oravg
lvcreate -L 10G -n sglaw_data14 oravg
lvcreate -L 10G -n sglaw_data15 oravg
lvcreate -L 10G -n sglaw_data16 oravg
lvcreate -L 10G -n sglaw_data17 oravg
lvcreate -L 10G -n sglaw_data18 oravg
lvcreate -L 10G -n sglaw_data19 oravg
lvcreate -L 10G -n sglaw_data20 oravg
lvcreate -L 10G -n sglaw_data21 oravg
lvcreate -L 10G -n sglaw_data22 oravg
lvcreate -L 10G -n sglaw_data23 oravg
lvcreate -L 10G -n sglaw_data24 oravg
lvcreate -L 10G -n sglaw_data25 oravg
lvcreate -L 10G -n sglaw_data26 oravg
lvcreate -L 10G -n sglaw_data27 oravg
lvcreate -L 10G -n sglaw_data28 oravg
lvcreate -L 10G -n sglaw_data29 oravg
lvcreate -L 10G -n sglaw_data30 oravg
lvcreate -L 1G -n sglaw_user01 oravg
创建的LV用于存放控制文件、日志文件和数据文件。Linux平台LVM的使用可以参考文章:http://space.itpub.net/23135684/viewspace-712121
二.创建物理字符设备文件 大家都知道块设备文件是不能作为数据文件或其他文件被直接使用的,必须创建块设备文件对应的字符设备文件。下面在/etc/rc.d/rc.local配置文件中加入如下语句,使得系统在启动的时候创建块设备文件对应的字符设备文件:
/bin/raw /dev/raw/raw1 /dev/oravg/sglaw_ctl01
/bin/raw /dev/raw/raw2 /dev/oravg/sglaw_ctl02
/bin/raw /dev/raw/raw3 /dev/oravg/sglaw_ctl03
/bin/raw /dev/raw/raw4 /dev/oravg/sglaw_redo01
/bin/raw /dev/raw/raw5 /dev/oravg/sglaw_redo02
/bin/raw /dev/raw/raw6 /dev/oravg/sglaw_redo03
/bin/raw /dev/raw/raw7 /dev/oravg/sglaw_redo04
/bin/raw /dev/raw/raw8 /dev/oravg/sglaw_data01
/bin/raw /dev/raw/raw9 /dev/oravg/sglaw_data02
/bin/raw /dev/raw/raw10 /dev/oravg/sglaw_data03
/bin/raw /dev/raw/raw11 /dev/oravg/sglaw_data04
/bin/raw /dev/raw/raw12 /dev/oravg/sglaw_data05
/bin/raw /dev/raw/raw13 /dev/oravg/sglaw_data06
/bin/raw /dev/raw/raw14 /dev/oravg/sglaw_data07
/bin/raw /dev/raw/raw15 /dev/oravg/sglaw_data08
/bin/raw /dev/raw/raw16 /dev/oravg/sglaw_data09
/bin/raw /dev/raw/raw17 /dev/oravg/sglaw_data10
/bin/raw /dev/raw/raw18 /dev/oravg/sglaw_data11
/bin/raw /dev/raw/raw19 /dev/oravg/sglaw_data12
/bin/raw /dev/raw/raw20 /dev/oravg/sglaw_data13
/bin/raw /dev/raw/raw21 /dev/oravg/sglaw_data14
/bin/raw /dev/raw/raw22 /dev/oravg/sglaw_data15
/bin/raw /dev/raw/raw23 /dev/oravg/sglaw_data16
/bin/raw /dev/raw/raw24 /dev/oravg/sglaw_data17
/bin/raw /dev/raw/raw25 /dev/oravg/sglaw_data18
/bin/raw /dev/raw/raw26 /dev/oravg/sglaw_data19
/bin/raw /dev/raw/raw27 /dev/oravg/sglaw_data20
/bin/raw /dev/raw/raw28 /dev/oravg/sglaw_data21
/bin/raw /dev/raw/raw29 /dev/oravg/sglaw_data22
/bin/raw /dev/raw/raw30 /dev/oravg/sglaw_data23
/bin/raw /dev/raw/raw31 /dev/oravg/sglaw_data24
/bin/raw /dev/raw/raw32 /dev/oravg/sglaw_data25
/bin/raw /dev/raw/raw33 /dev/oravg/sglaw_data26
/bin/raw /dev/raw/raw34 /dev/oravg/sglaw_data27
/bin/raw /dev/raw/raw35 /dev/oravg/sglaw_data28
/bin/raw /dev/raw/raw36 /dev/oravg/sglaw_data29
/bin/raw /dev/raw/raw37 /dev/oravg/sglaw_data30
/bin/raw /dev/raw/raw38 /dev/oravg/sglaw_user01
/bin/chown oracle:oinstall /dev/raw/*
使用raw命令创建块设备文件对应的字符设备文件,将所有字符设备文件的所有者权限修改为oracle:oinstall。如果磁盘是从存储挂载过来的多张磁盘,且每个磁盘15个分区足够的话,那么也可不选择使用LVM,可以通过使用udev的方式来创建分区对应的裸设备字符文件。使用udev绑定裸设备的相关内容可以参考:http://space.itpub.net/23135684/viewspace-696799
三.创建块设备文件对应的链接文件 创建链接文件的目的在于通过链接文件的名称可以判断出文件的用途、大小等自定义含义,有利于日常的管理工作,执行下面的命令创建字符设备文件对应的链接文件:
ln -s /dev/raw/raw1 /u01/app/oracle/oradata/sglawdb/control01.ctl
ln -s /dev/raw/raw2 /u01/app/oracle/oradata/sglawdb/control02.ctl
ln -s /dev/raw/raw3 /u01/app/oracle/oradata/sglawdb/control03.ctl
ln -s /dev/raw/raw4 /u01/app/oracle/oradata/sglawdb/redo01.log
ln -s /dev/raw/raw5 /u01/app/oracle/oradata/sglawdb/redo02.log
ln -s /dev/raw/raw6 /u01/app/oracle/oradata/sglawdb/redo03.log
ln -s /dev/raw/raw7 /u01/app/oracle/oradata/sglawdb/redo04.log
ln -s /dev/raw/raw8 /u01/app/oracle/oradata/sglawdb/data01.dbf
ln -s /dev/raw/raw9 /u01/app/oracle/oradata/sglawdb/data02.dbf
ln -s /dev/raw/raw10 /u01/app/oracle/oradata/sglawdb/data03.dbf
ln -s /dev/raw/raw11 /u01/app/oracle/oradata/sglawdb/data04.dbf
ln -s /dev/raw/raw12 /u01/app/oracle/oradata/sglawdb/data05.dbf
ln -s /dev/raw/raw13 /u01/app/oracle/oradata/sglawdb/data06.dbf
ln -s /dev/raw/raw14 /u01/app/oracle/oradata/sglawdb/data07.dbf
ln -s /dev/raw/raw15 /u01/app/oracle/oradata/sglawdb/data08.dbf
ln -s /dev/raw/raw16 /u01/app/oracle/oradata/sglawdb/data09.dbf
ln -s /dev/raw/raw17 /u01/app/oracle/oradata/sglawdb/data10.dbf
ln -s /dev/raw/raw18 /u01/app/oracle/oradata/sglawdb/data11.dbf
ln -s /dev/raw/raw19 /u01/app/oracle/oradata/sglawdb/data12.dbf
ln -s /dev/raw/raw20 /u01/app/oracle/oradata/sglawdb/data13.dbf
ln -s /dev/raw/raw21 /u01/app/oracle/oradata/sglawdb/data14.dbf
ln -s /dev/raw/raw22 /u01/app/oracle/oradata/sglawdb/data15.dbf
ln -s /dev/raw/raw23 /u01/app/oracle/oradata/sglawdb/data16.dbf
ln -s /dev/raw/raw24 /u01/app/oracle/oradata/sglawdb/data17.dbf
ln -s /dev/raw/raw25 /u01/app/oracle/oradata/sglawdb/data18.dbf
ln -s /dev/raw/raw26 /u01/app/oracle/oradata/sglawdb/data19.dbf
ln -s /dev/raw/raw27 /u01/app/oracle/oradata/sglawdb/data20.dbf
ln -s /dev/raw/raw28 /u01/app/oracle/oradata/sglawdb/data21.dbf
ln -s /dev/raw/raw29 /u01/app/oracle/oradata/sglawdb/data22.dbf
ln -s /dev/raw/raw30 /u01/app/oracle/oradata/sglawdb/data23.dbf
ln -s /dev/raw/raw31 /u01/app/oracle/oradata/sglawdb/data24.dbf
ln -s /dev/raw/raw32 /u01/app/oracle/oradata/sglawdb/data25.dbf
ln -s /dev/raw/raw33 /u01/app/oracle/oradata/sglawdb/data26.dbf
ln -s /dev/raw/raw34 /u01/app/oracle/oradata/sglawdb/data27.dbf
ln -s /dev/raw/raw35 /u01/app/oracle/oradata/sglawdb/data28.dbf
ln -s /dev/raw/raw36 /u01/app/oracle/oradata/sglawdb/data29.dbf
ln -s /dev/raw/raw37 /u01/app/oracle/oradata/sglawdb/data30.dbf
ln -s /dev/raw/raw38 /u01/app/oracle/oradata/sglawdb/user01.dbf
以上是这次在Linux平台使用裸设备作为存储方式创建数据库,有关裸设备文件创建的记录,以及对以前关于裸设备文章的补充。
--end--