首页 > Linux, 系统服务 > raw裸设备绑定和赋加权限方法(不同版本系统、不同绑定方式)之LVM篇

raw裸设备绑定和赋加权限方法(不同版本系统、不同绑定方式)之LVM篇

上一篇介绍的是普通设备做为raw裸设备的制作方法,现在简单介绍下,使用lv来做raw裸设备绑定步骤。

二、LV设备做成raw裸设备

依旧拿RedFlag DC Server 5.0 和Asianux 3.0系统来做实验,因为udev版本不同,所以,设置方法也会不同。

前提:
有三个lv设备,/dev/mapper/vg1-lv–raw1、 /dev/mapper/vg1-lv–raw2、 /dev/mapper/vg1-lv–raw3 ,将这三个设备分别做成raw1、raw2、raw3,属主是oracle,属组是dba,权限是0640。

1、RedFlag DC Server 5.0 SP4 (内核2.6.9-89.5AXS2)
(1) raw设备绑定
依旧使用 rawdevices 配置文件来控制。

[root@localhost ~]#vi  /etc/sysconfig/rawdevices
# This file and interface are deprecated.
# Applications needing raw device access should open regular
# block devices with O_DIRECT.
# raw device bindings
# format:  <rawdev> <major> <minor>
#          <rawdev> <blockdev>
# example: /dev/raw/raw1 /dev/sda1
#          /dev/raw/raw2 8 5
/dev/raw/raw1   /dev/mapper/vg1-lv--raw1
/dev/raw/raw2   /dev/mapper/vg1-lv--raw2
/dev/raw/raw3   /dev/mapper/vg1-lv--raw3

(2) 赋加权限
权限的控制,依旧在udev下的permissions.d 目录中设置,找到下面类似信息,进行修改:

# raw devices
ram*:root:disk:0660
#raw/*:root:disk:0660
raw/*:oracle:dba:0640

(3) 重启udev服务,使其生效
修改完配置后,可以执行

[root@localhost ~]#start_udev

我们来看下效果:

[root@localhost ~]# cd /dev/raw
[root@localhost raw]# ll
total 0
crw-r-----  1 oracle dba 162, 1 Feb 26 17:39 raw1
crw-r-----  1 oracle dba 162, 2 Feb 26 17:39 raw2
crw-r-----  1 oracle dba 162, 3 Feb 26 17:39 raw3
[root@localhost raw]# raw -qa
/dev/raw/raw1:  bound to major 253, minor 2
/dev/raw/raw2:  bound to major 253, minor 3
/dev/raw/raw3:  bound to major 253, minor 4

2、Asianux 3.0 SP2 (内核 2.6.18-128.7AXS3)
(1) raw设备绑定
依旧是udev来管理。

[root@localhost rules.d]# vi 60-raw.rules
# Enter raw device bindings here.
#
# An example would be:
#   ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
#   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.
KERNEL!="dm-[0-9]*", GOTO="skip_dm"
PROGRAM!="/sbin/dmsetup ls --exec /bin/basename -j %M -m %m", GOTO="skip_dm"
RESULT=="vg1-lv--raw1", RUN+="/bin/raw /dev/raw/raw1 /dev/mapper/vg1-lv--raw1"
RESULT=="vg1-lv--raw2", RUN+="/bin/raw /dev/raw/raw2 /dev/mapper/vg1-lv--raw2"
RESULT=="vg1-lv--raw3", RUN+="/bin/raw /dev/raw/raw3 /dev/mapper/vg1-lv--raw3"
LABEL="skip_dm"

还需要修改一处地方,但这处地方由于版本不同,而位置有所不同

Asianux3sp1(2.6.18-53.11)时,需要修改 /etc/udev/rules.d/50-udev.rules 文件,找到如下内容进行修改:

#KERNEL=="dm-[0-9]*", ACTION=="add", OPTIONS+="ignore_device"
KERNEL=="dm-[0-9]*", ACTION=="add"

Asianux3sp2(2.6.18-128.7)以上,需要修改 /etc/udev/rules.d/90-dm.rules 文件,找到如下内容进行修改:

#KERNEL=="dm-[0-9]*", ACTION=="add", OPTIONS+="ignore_device"
KERNEL=="dm-[0-9]*", ACTION=="add"

(2) 赋加权限
权限的控制,依旧在udev下的60-raw.rules文件修改:

# Enter raw device bindings here.
#
# An example would be:
#   ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
#   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.
KERNEL!="dm-[0-9]*", GOTO="skip_dm"
PROGRAM!="/sbin/dmsetup ls --exec /bin/basename -j %M -m %m", GOTO="skip_dm"
RESULT=="vg1-lv--raw1", RUN+="/bin/raw /dev/raw/raw1 /dev/mapper/vg1-lv--raw1"
RESULT=="vg1-lv--raw2", RUN+="/bin/raw /dev/raw/raw2 /dev/mapper/vg1-lv--raw2"
RESULT=="vg1-lv--raw3", RUN+="/bin/raw /dev/raw/raw3 /dev/mapper/vg1-lv--raw3"
LABEL="skip_dm"
KERNEL=="raw1", OWNER=="oracle", GROUP=="dba", MODE=="0640"
KERNEL=="raw2", OWNER=="oracle", GROUP=="dba", MODE=="0640"
KERNEL=="raw3", OWNER=="oracle", GROUP=="dba", MODE=="0640"

(3) 重启udev服务,使其生效
修改完配置后,可以执行

[root@localhost ~]#start_udev

看看是否生效:

[root@localhost raw]# ll
total 0
crw-r----- 1 oracle dba 162, 1 Jun 17 13:21 raw1
crw-r----- 1 oracle dba 162, 2 Jun 17 13:21 raw2
crw-r----- 1 oracle dba 162, 3 Jun 17 13:21 raw3
[root@localhost raw]# raw -qa
/dev/raw/raw1:  bound to major 253, minor 2
/dev/raw/raw2:  bound to major 253, minor 3
/dev/raw/raw3:  bound to major 253, minor 4


转载本站文章请注明,来自: Edward's Blog

本文链接: http://www.edward-han.com/176.html

分类: Linux, 系统服务 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.
您必须启用 javascript 才能在这儿看到验证码!

无觅相关文章插件,快速提升流量

加载中……