Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3127290
  • 博文数量: 710
  • 博客积分: 14546
  • 博客等级: 上将
  • 技术积分: 6738
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-30 10:20
文章分类

全部博文(710)

文章存档

2016年(1)

2014年(7)

2013年(22)

2012年(227)

2011年(322)

2009年(119)

2008年(12)

分类: LINUX

2011-08-01 13:25:02

方法一、和rhel4相同,但是需要手动添加。
1.添加启动脚本
  1. vi /etc/init.d/rawdevices 
  2. #!/bin/bash
  3. #
  4. # rawdevices This shell script assignes rawdevices to block devices
  5. #
  6. # chkconfig: 345 56 44
  7. # description: This scripts assignes raw devices to block devices \
  8. # (such as hard drive partitions). This is for the use \
  9. # of applications such as Oracle. You can set up the \
  10. # raw device to block device mapping by editing \
  11. # the file /etc/sysconfig/rawdevices.
  12. #
  13. # config: /etc/sysconfig/rawdevices

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

  18. . /etc/init.d/functions

  19. function assign_raw()
  20. {
  21.    LC_ALL=C egrep -v '^ *#' /etc/sysconfig/rawdevices |
  22.    while read RAW BLOCK; do
  23.      if [ -n "$RAW" -a -n "$BLOCK" ]; then
  24.          rawdirname=${RAW%/*}
  25.          if [ "$rawdirname" = "/dev" -a -d /dev/raw ]; then
  26.            echo $" Please correct your /etc/sysconfig/rawdevices:"
  27.            echo $" rawdevices are now located in the directory /dev/raw/ "
  28.            echo $" If the command 'raw' still refers to /dev/raw as a file."
  29.            echo $" you'll have to upgrade your util-linux package"
  30.            exit 0
  31.          fi
  32.          if [ "$rawdirname" = "/dev/raw" -a -f /dev/raw ]; then
  33.            echo $" Please correct your /etc/sysconfig/rawdevices:"
  34.            echo $" rawdevices are now located in the directory /dev/raw/ "
  35.            echo $" If the command 'raw' still refers to /dev/raw as a file."
  36.            echo $" you'll have to upgrade your util-linux package"
  37.            exit 0
  38.          fi

  39.        echo " $RAW --> $BLOCK";
  40.        raw $RAW $BLOCK
  41.      fi
  42.    done
  43. }

  44. # See how we were called.
  45. case "$1" in
  46.   start)
  47.         # Assign devices
  48.         echo $"Assigning devices: "
  49.         assign_raw
  50.         echo $"done"
  51.         ;;
  52.   stop)
  53.         # No action to be taken here
  54.         ;;

  55.   status)
  56.         ID=`id -u`
  57.         if [ $ID -eq 0 ]; then
  58.           raw -qa
  59.         else
  60.           echo $"You need to be root to use this command ! "
  61.         fi
  62.         ;;

  63.   restart|reload)
  64.         $0 start
  65.         ;;

  66.   *)
  67.         echo $"Usage: $0 {start|stop|status|restart}"
  68.         exit 1
  69. esac

  70. exit 0
以上部分使用multipath也可以代替。

2.指定
  1. [root@rac1 ~]# cat /etc/sysconfig/rawdevices
  2. /dev/raw/raw1 /dev/iscsi/rac_storage_1/part1
  3. /dev/raw/raw2 /dev/iscsi/rac_storage_2/part1
3.添加到开机启动
  1. [root@rac1 ~]#chkconfig --add rawdevices
4.重新启动 OK

方法二、rhel5推荐的正规方法
1.添加规则
  1. [root@rac1 ~]# cat /etc/udev/rules.d/60-raw.rules
  2. ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
2.重启机器或 start_udev ,OK!






阅读(1435) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~