Linux 下 oracle裸设备
一块物理盘或一个partition 都能创建一个 PV ,从而用于创建 VG
1、fdisk 创建了一个分区 /dev/sdb1
2、raw绑定
#raw /dev/raw/raw1 /dev/sdb1 //必须是 /dev/raw/rawX 的格式
3、绑定后生成一个文件/dev/raw/raw1 记录绑定的信息.如果不想要直接删除这个文件就行了.
在AS 4 中:
但是这个文件在os reboot之后就没有了.所以要把raw的信息记录到 /etc/sysconfig/rawdevices 文件中,
这样重启之后就能保留住raw的信息了.
格式:
/dev/raw/raw1 /dev/sdb1
在RHEL5中:
#vi /etc/udev/rules.d/60-raw.rules
# An example would be:
# ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or (注意两个都要加,否则裸设备激活不了. 在RHEL5.2上,也激活不了。rhel5.3 没问题)
# 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", ENV{MAJOR}=="8", ENV{MINOR}=="2", RUN+="/bin/raw /dev/raw/raw2 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw1 %M %m"
ACTION=="add", KERNEL=="test/lvtest", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="test/lvtest1", RUN+="/bin/raw /dev/raw/raw2 %N"
######################
在系统中如果存在 AS4 中:/etc/sysconfig/rawdevices 格式的文件,那么可以用以下脚本生成上面格式。
#!/bin/sh
grep -v "^ *#" /etc/sysconfig/rawdevices | grep -v "^$" | while read dev major minor ; do
if [ -z "$minor" ]; then
echo "ACTION==\"add\", KERNEL==\"${major##/dev/}\", RUN+=\"/usr/bin/raw $dev %N\""
else
echo "ACTION==\"add\", ENV{MAJOR}==\"$major\", ENV{MINOR}==\"$minor\", RUN+=\"/usr/bin/raw $dev %M %m\""
fi
done
-------------------------------------------------------------------
oracle 中的裸设备的建立
1、对一个磁盘进行分区
#fdisk /dev/cciss/c0d0
作出一个分区 /dev/cciss/c0d0p8
2、创建一个PV
#pvcreate /dev/cciss/c0d0p8
3、创建一个VG
#vgcreate vgdata /dev/cciss/c0d0p8
4、创建一个LV
lvcreate -L 512M -n systems_2g vgdata
lvcreate -L 512M -n users_512m vgdata
lvcreate -L 512M -n temp_512m vgdata
lvcreate -L 2048M -n undotbs1_2g vgdata
lvcreate -L 2048M -n undotbs2_2g vgdata
lvcreate -L 512M -n cntrl1_512m vgdata
lvcreate -L 512M -n cntrl2_512m vgdata
lvcreate -L 512M -n cntrl3_512m vgdata
lvcreate -L 1024M -n log11_1g vgdata
lvcreate -L 1024M -n log12_1g vgdata
lvcreate -L 1024M -n log21_1g vgdata
lvcreate -L 1024M -n log22_1g vgdata
lvcreate -L 1024M -n log31_1g vgdata
lvcreate -L 1024M -n log32_1g vgdata
lvcreate -L 512M -n spfile_512m vgdata
lvcreate -L 512M -n indx_512m vgdata
lvcreate -L 512M -n tools_512m vgdata
lvcreate -L 2048M -n sysaux_2g vgdata
5、生成裸设备文件
raw /dev/raw/raw1 /dev/vgdata/systems_2g
raw /dev/raw/raw2 /dev/vgdata/users_512m
raw /dev/raw/raw3 /dev/vgdata/temp_512m
raw /dev/raw/raw4 /dev/vgdata/undotbs1_2g
raw /dev/raw/raw5 /dev/vgdata/undotbs2_2g
raw /dev/raw/raw6 /dev/vgdata/cntrl1_512m
raw /dev/raw/raw7 /dev/vgdata/cntrl2_512m
raw /dev/raw/raw8 /dev/vgdata/cntrl3_512m
raw /dev/raw/raw9 /dev/vgdata/log11_1g
raw /dev/raw/raw10 /dev/vgdata/log12_1g
raw /dev/raw/raw11 /dev/vgdata/log21_1g
raw /dev/raw/raw12 /dev/vgdata/log22_1g
raw /dev/raw/raw13 /dev/vgdata/log31_1g
raw /dev/raw/raw14 /dev/vgdata/log32_1g
raw /dev/raw/raw15 /dev/vgdata/spfile_512m
raw /dev/raw/raw16 /dev/vgdata/indx_512m
raw /dev/raw/raw17 /dev/vgdata/tools_512m
raw /dev/raw/raw18 /dev/vgdata/sysaux_2g
6、设置开机自动加载 裸设备
由于开机时,/dev/raw/rawX 就不存在,所以要通过 udevd damone (udevd -d 守护进程)
# vi /etc/udev/rules.d/60-raw.rules (假如这种方法失效,那么5、生成裸设备文件 命令加到 rc.local 中执行)
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw1 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="2", RUN+="/bin/raw /dev/raw/raw2 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="3", RUN+="/bin/raw /dev/raw/raw3 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="4", RUN+="/bin/raw /dev/raw/raw4 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="5", RUN+="/bin/raw /dev/raw/raw5 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="6", RUN+="/bin/raw /dev/raw/raw6 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="7", RUN+="/bin/raw /dev/raw/raw7 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="8", RUN+="/bin/raw /dev/raw/raw8 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="9", RUN+="/bin/raw /dev/raw/raw9 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="10", RUN+="/bin/raw /dev/raw/raw10 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="11", RUN+="/bin/raw /dev/raw/raw11 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="12", RUN+="/bin/raw /dev/raw/raw12 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="13", RUN+="/bin/raw /dev/raw/raw13 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="14", RUN+="/bin/raw /dev/raw/raw14 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="15", RUN+="/bin/raw /dev/raw/raw15 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="16", RUN+="/bin/raw /dev/raw/raw16 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="17", RUN+="/bin/raw /dev/raw/raw17 %M %m"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="18", RUN+="/bin/raw /dev/raw/raw18 %M %m"
ACTION=="add", KERNEL=="vgdata/systems_2g ", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="vgdata/users_512m", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="vgdata/temp_512m", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="vgdata/undotbs1_2g", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="vgdata/undotbs2_2g", RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", KERNEL=="vgdata/cntrl1_512m", RUN+="/bin/raw /dev/raw/raw6 %N"
ACTION=="add", KERNEL=="vgdata/cntrl2_512m", RUN+="/bin/raw /dev/raw/raw7 %N"
ACTION=="add", KERNEL=="vgdata/cntrl3_512m", RUN+="/bin/raw /dev/raw/raw8 %N"
ACTION=="add", KERNEL=="vgdata/log11_1g", RUN+="/bin/raw /dev/raw/raw9 %N"
ACTION=="add", KERNEL=="vgdata/log12_1g", RUN+="/bin/raw /dev/raw/raw10 %N"
ACTION=="add", KERNEL=="vgdata/log21_1g", RUN+="/bin/raw /dev/raw/raw11 %N"
ACTION=="add", KERNEL=="vgdata/log22_1g", RUN+="/bin/raw /dev/raw/raw12 %N"
ACTION=="add", KERNEL=="vgdata/log31_1g", RUN+="/bin/raw /dev/raw/raw13 %N"
ACTION=="add", KERNEL=="vgdata/log32_1g", RUN+="/bin/raw /dev/raw/raw14 %N"
ACTION=="add", KERNEL=="vgdata/spfile_512m", RUN+="/bin/raw /dev/raw/raw15 %N"
ACTION=="add", KERNEL=="vgdata/indx_512m", RUN+="/bin/raw /dev/raw/raw16 %N"
ACTION=="add", KERNEL=="vgdata/tools_512m", RUN+="/bin/raw /dev/raw/raw17 %N"
ACTION=="add", KERNEL=="vgdata/sysaux_2g ", RUN+="/bin/raw /dev/raw/raw18 %N"
7、#/etc/rc.local 启动文件修改
ln -s /dev/raw/raw1 /opt/oracle/oradata/hisdb/systems_2g
ln -s /dev/raw/raw2 /opt/oracle/oradata/hisdb/users_512m
ln -s /dev/raw/raw3 /opt/oracle/oradata/hisdb/temp_512m
ln -s /dev/raw/raw4 /opt/oracle/oradata/hisdb/undotbs1_2g
ln -s /dev/raw/raw5 /opt/oracle/oradata/hisdb/undotbs2_2g
ln -s /dev/raw/raw6 /opt/oracle/oradata/hisdb/cntrl1_512m
ln -s /dev/raw/raw7 /opt/oracle/oradata/hisdb/cntrl2_512m
ln -s /dev/raw/raw8 /opt/oracle/oradata/hisdb/cntrl3_512m
ln -s /dev/raw/raw9 /opt/oracle/oradata/hisdb/log11_1g
ln -s /dev/raw/raw10 /opt/oracle/oradata/hisdb/log12_1g
ln -s /dev/raw/raw11 /opt/oracle/oradata/hisdb/log21_1g
ln -s /dev/raw/raw12 /opt/oracle/oradata/hisdb/log22_1g
ln -s /dev/raw/raw13 /opt/oracle/oradata/hisdb/log31_1g
ln -s /dev/raw/raw14 /opt/oracle/oradata/hisdb/log32_1g
ln -s /dev/raw/raw15 /opt/oracle/oradata/hisdb/spfile_512m
ln -s /dev/raw/raw16 /opt/oracle/oradata/hisdb/indx_512m
ln -s /dev/raw/raw17 /opt/oracle/oradata/hisdb/tools_512m
ln -s /dev/raw/raw18 /opt/oracle/oradata/hisdb/sysaux_2g
chown oracle:dba /dev/raw/raw*
chown -R oracle:dba /dev/mapper
注意: 做完这些记得重启服务器验证rawdevices 是否加载成功
# raw -aq 是否输出 raw 信息
#ls -l /dev/raw/ 是否存在,并且属主是否为oracle:oinstall
授权
chown -R oracle:dba /dev/mapper
修改配置文件/etc/udev/permissions.d/50-udev.permissions (但是发现系统里面没有这个文件,没办法做)
注释掉raw/*:root:disk:0660
添加新行raw/*:oracle:dba:0660
8、数据库建库前做一些相关修改
#vi .bash_profile 增加
#export DBCA_RAW_CONFIG=/home/oracle/raw.info
#vi /home/oracle/raw.info 建库的裸设备映射文件
system=/opt/oracle/oradata/hisdb/systems_2g
users=/opt/oracle/oradata/hisdb/users_512m
temp=/opt/oracle/oradata/hisdb/temp_512m
undotbs1=/opt/oracle/oradata/hisdb/undotbs1_2g
undotbs2=/opt/oracle/oradata/hisdb/undotbs2_2g
control1=/opt/oracle/oradata/hisdb/cntrl1_512m
control2=/opt/oracle/oradata/hisdb/cntrl2_512m
control3=/opt/oracle/oradata/hisdb/cntrl3_512m
redo1_1=/opt/oracle/oradata/hisdb/log11_1g
redo1_2=/opt/oracle/oradata/hisdb/log12_1g
redo2_1=/opt/oracle/oradata/hisdb/log21_1g
redo2_2=/opt/oracle/oradata/hisdb/log22_1g
redo3_1=/opt/oracle/oradata/hisdb/log31_1g
redo3_2=/opt/oracle/oradata/hisdb/log32_1g
spfile=/opt/oracle/oradata/hisdb/spfile_512m
indx=/opt/oracle/oradata/hisdb/indx_512m
tools=/opt/oracle/oradata/hisdb/tools_512m
sysaux=/opt/oracle/oradata/hisdb/sysaux_2g
RHEL5 的新特性: