linux创建raw设备
总结一下,看了一下他们的blog,几乎没有谁详细的总结raw的创建。
其实raw设备创建要分多路径链路创建和普通创建。
[root@localhost dev]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 241G 6.3G 222G 3% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 32G 0 32G 0% /dev/shm
[root@localhost dev]# multipath -ll
mpath2 (36d4ae52000a8364a000003bc50f4ef28) dm-1 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:0:0 sdab 65:176 [active][ready]
\_ 1:0:1:0 sdo 8:224 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:1:0 sdao 66:128 [active][ghost]
\_ 1:0:0:0 sdb 8:16 [active][ghost]
mpath1 (36d4ae52000a835fb0000033c50f0853d) dm-0 DELL,Universal Xport
[size=20M][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=4][active]
\_ 1:0:1:31 sdaa 65:160 [active][ready]
\_ 2:0:0:31 sdan 66:112 [active][ready]
\_ 2:0:1:31 sdba 67:64 [active][ready]
\_ 1:0:0:31 sdn 8:208 [active][ready]
mpath0 (36d4ae52000a8364a000003c550f4ef74) dm-12 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:0:11 sdam 66:96 [active][ready]
\_ 1:0:1:11 sdz 65:144 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:1:11 sdaz 67:48 [active][ghost]
\_ 1:0:0:11 sdm 8:192 [active][ghost]
mpath9 (36d4ae52000a8364a000003c150f4ef4e) dm-8 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:0:7 sdai 66:32 [active][ready]
\_ 1:0:1:7 sdv 65:80 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:1:7 sdav 66:240 [active][ghost]
\_ 1:0:0:7 sdi 8:128 [active][ghost]
mpath8 (36d4ae52000a835fb000003d150f4f655) dm-7 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:1:6 sdau 66:224 [active][ready]
\_ 1:0:0:6 sdh 8:112 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:0:6 sdah 66:16 [active][ghost]
\_ 1:0:1:6 sdu 65:64 [active][ghost]
mpath7 (36d4ae52000a8364a000003bf50f4ef3a) dm-6 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:0:5 sdag 66:0 [active][ready]
\_ 1:0:1:5 sdt 65:48 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:1:5 sdat 66:208 [active][ghost]
\_ 1:0:0:5 sdg 8:96 [active][ghost]
mpath6 (36d4ae52000a835fb000003cf50f4f643) dm-5 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:1:4 sdas 66:192 [active][ready]
\_ 1:0:0:4 sdf 8:80 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:0:4 sdaf 65:240 [active][ghost]
\_ 1:0:1:4 sds 65:32 [active][ghost]
mpath12 (36d4ae52000a835fb000003d550f4f679) dm-11 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:1:10 sday 67:32 [active][ready]
\_ 1:0:0:10 sdl 8:176 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:0:10 sdal 66:80 [active][ghost]
\_ 1:0:1:10 sdy 65:128 [active][ghost]
mpath5 (36d4ae52000a835fb000003d950f4f69e) dm-4 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:1:3 sdar 66:176 [active][ready]
\_ 1:0:0:3 sde 8:64 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:0:3 sdae 65:224 [active][ghost]
\_ 1:0:1:3 sdr 65:16 [active][ghost]
mpath11 (36d4ae52000a8364a000003c350f4ef5f) dm-10 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:0:9 sdak 66:64 [active][ready]
\_ 1:0:1:9 sdx 65:112 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:1:9 sdax 67:16 [active][ghost]
\_ 1:0:0:9 sdk 8:160 [active][ghost]
mpath4 (36d4ae52000a8364a000003c750f4ef85) dm-3 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:0:2 sdad 65:208 [active][ready]
\_ 1:0:1:2 sdq 65:0 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:1:2 sdaq 66:160 [active][ghost]
\_ 1:0:0:2 sdd 8:48 [active][ghost]
mpath10 (36d4ae52000a835fb000003d350f4f667) dm-9 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:1:8 sdaw 67:0 [active][ready]
\_ 1:0:0:8 sdj 8:144 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:0:8 sdaj 66:48 [active][ghost]
\_ 1:0:1:8 sdw 65:96 [active][ghost]
mpath3 (36d4ae52000a835fb000003d750f4f68d) dm-2 DELL,MD32xx
[size=1.8T][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:1:1 sdap 66:144 [active][ready]
\_ 1:0:0:1 sdc 8:32 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 2:0:0:1 sdac 65:192 [active][ghost]
\_ 1:0:1:1 sdp 8:240 [active][ghost]
[root@localhost dev]# ls /dev/mapper/
control mpath0p1 mpath10 mpath11 mpath12 mpath2 mpath3 mpath4 mpath5 mpath6 mpath7 mpath8 mpath9
mpath0 mpath1 mpath10p1 mpath11p1 mpath12p1 mpath2p1 mpath3p1 mpath4p1 mpath5p1 mpath6p1 mpath7p1 mpath8p1 mpath9p1
[root@localhost dev]# ls /dev/mapper/
control mpath0p1 mpath10 mpath11 mpath12 mpath2 mpath3 mpath4 mpath5 mpath6 mpath7 mpath8 mpath9
mpath0 mpath1 mpath10p1 mpath11p1 mpath12p1 mpath2p1 mpath3p1 mpath4p1 mpath5p1 mpath6p1 mpath7p1 mpath8p1 mpath9p1
---情况二 (不是多路径)
[root@DP1 ~]# more /etc/sysconfig/rawdevices
# raw device bindings
# format: <rawdev> <major> <minor>
# <rawdev> <blockdev>
# example: /dev/raw/raw1 /dev/sda1
# /dev/raw/raw2 8 5
#crs
/dev/raw/raw1 /dev/sdb1
#data
/dev/raw/raw2 /dev/sdb2
/dev/raw/raw3 /dev/sdd
/dev/raw/raw4 /dev/sdh
/dev/raw/raw5 /dev/sdj
[root@DP1 ~]#
设置权限
vi /etc/rc.local
[oracle@DP2 dbs]$ more /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
chown grid:oinstall /dev/raw/raw1
chown grid:oinstall /dev/raw/raw2
chown grid:oinstall /dev/raw/raw3
chown grid:oinstall /dev/raw/raw4
chmod 660 /dev/raw/raw1
chmod 660 /dev/raw/raw2
chmod 660 /dev/raw/raw3
chmod 660 /dev/raw/raw4
touch /var/lock/subsys/local
删除裸设备
raw /dev/raw/raw1 0 0
使裸设备重启
/etc/init.d/rawdevices restart
--查看裸设备
[root@DP2 product]# raw -qa
/dev/raw/raw1: bound to major 8, minor 16
/dev/raw/raw2: bound to major 8, minor 48
/dev/raw/raw3: bound to major 8, minor 112
/dev/raw/raw4: bound to major 8, minor 144
[root@DP2 product]#
另一种配置方式, 通用于linux5.x 和linux6.x
vi /etc/udev/rules.d/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 -- 注意这里有个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.
比如:
fdisk -l
Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[root@SE ~]# more /etc/udev/rules.d/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.
ACTION=="add", KERNEL=="sdc", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdd", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="raw[1-2]", OWNER="grid", GROUP="oinstall", MODE="660"
[root@SE ~]# start_udev
[root@SE ~]# raw -qa
/dev/raw/raw1: bound to major 8, minor 32
/dev/raw/raw2: bound to major 8, minor 48
更多推荐
所有评论(0)