Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2385562
  • 博文数量: 384
  • 博客积分: 10193
  • 博客等级: 上将
  • 技术积分: 3785
  • 用 户 组: 普通用户
  • 注册时间: 2005-06-09 18:02
文章分类

全部博文(384)

文章存档

2011年(10)

2010年(29)

2009年(39)

2008年(36)

2007年(43)

2006年(198)

2005年(29)

分类: LINUX

2006-09-28 15:21:23

建立文件/etc/rawconfig,内容如下
# This file and interface are deprecated.
# Applications needing raw device access should open regular
# block devices with O_DIRECT.
# raw device bindings
# format:
#
# example: /dev/raw/raw1 /dev/sda1
# /dev/raw/raw2 8 5
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdb2
/dev/raw/raw3 /dev/sdb3
/dev/raw/raw4 /dev/sdb4

建立文件/etc/init.d/rawdevices,内容如下:
#!/bin/bash
#
# rawdevices This shell script assignes rawdevices to block devices
#
# chkconfig: 345 56 44
# description: This scripts assignes raw devices to block devices \
# (such as hard drive partitions). This is for the use \
# of applications such as Oracle. You can set up the \
# raw device to block device mapping by editing \
# the file /etc/sysconfig/rawdevices. Note that the use \
# of raw devices is deprecated, and applications should \
# open regular block devices with O_DIRECT instead.
#
# config: /etc/sysconfig/rawdevices

[ -f /sbin/raw ] || exit 0
[ -f /etc/rawconfig ] || exit 0
# Exit if the file just has the default comments.
LC_ALL=C /bin/egrep -q -v "^ *#" /etc/rawconfig 2>/dev/null || exit 0



function assign_raw()
{
LC_ALL=C egrep -v '^ *#' /etc/rawconfig |
while read RAW BLOCK; do
if [ -n "$RAW" -a -n "$BLOCK" ]; then
rawdirname=${RAW%/*}
if [ "$rawdirname" = "/dev" -a -d /dev/raw ]; then
echo $" Please correct your /etc/rawconfig:"
echo $" rawdevices are now located in the directory /dev/raw/ "
echo $" If the command 'raw' still refers to /dev/raw as a file."
echo $" you'll have to upgrade your util-linux package"
exit 0
fi
if [ "$rawdirname" = "/dev/raw" -a -f /dev/raw ]; then
echo $" Please correct your /etc/rawconfig:"
echo $" rawdevices are now located in the directory /dev/raw/ "
echo $" If the command 'raw' still refers to /dev/raw as a file."
echo $" you'll have to upgrade your util-linux package"
exit 0
fi

echo " $RAW --> $BLOCK";
raw $RAW $BLOCK
fi
done
}

# See how we were called.
case "$1" in
start)
# Assign devices
echo $"Assigning devices: "
assign_raw
echo $"done"
;;
stop)
# No action to be taken here
;;

status)
ID=`id -u`
if [ $ID -eq 0 ]; then
raw -qa
else
echo $"You need to be root to use this command ! "
fi
;;

restart|reload)
$0 start
;;

*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac

exit 0

chmod a+x /etc/init.d/rawdevices
ln -s /etc/init.d/rawdevices /etc/rc2.d/S20rawdevices
cd /dev;./MAKEDEV raw
/etc/init.d/rawdevices restart
可以使用raw -qa查询raw绑定的情况

设置裸设备的权限
chown oracle:oinstall /dev/raw/raw*;ls -al /dev/raw
阅读(2535) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~